Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#1832·flysystem

Root folder is not created when missing (sftp)

Author: ionutantohiCreated Nov 22, 2024Updated Sep 18, 2026

Bug Report

Q A
Flysystem Version 3.29.1
Adapter Name SftpAdapter
Adapter version 3.29.0

Summary

Root folder is not created when is missing and UnableToWriteFile exception is thrown

Note: It is created though if the path contains a prefix.

How to reproduce

php
use League\Flysystem\Config;
use League\Flysystem\PhpseclibV3\SftpAdapter;
use League\Flysystem\PhpseclibV3\SftpConnectionProvider;

$provider = SftpConnectionProvider::fromArray([
    'driver' => 'sftp',
    'host' => 'domain',
    'username' => 'username',
    'password' => 'password',
]);


$adapter = new SftpAdapter(
    connectionProvider: $provider,
    root: 'uploads'
);

// Make sure that "uploads" folder is missing on remote server before each test

// ❌ Case 1: UnableToWriteFile exception is thrown
// I expect to work and file to be uploaded at /uploads/file.txt
$adapter->write('file.txt', 'content', new Config());


// ✅ Case 2: File is uploaded at /uploads/parent_folder/file.txt even if the "uploads" folder doesn't exist
$adapter->write('parent_folder/file.txt', 'content', new Config());

Source: thephpleague/flysystem

View original on GitHubView discussion on GitHub