I have the following class for uploading files in a directory, however, the first directory that should be created is getting set up as \'File\' rather then a \'File Folder\'. B
It works for me. I tried $sftp->mkdir('Test folder')
and $sftp->mkdir('./Test folder/Another folder')
. The directories that were created were created as expected.
One thing to keep in mind... DIRECTORY_SEPARATOR
is probably not the best thing to use in this instance. On Windows, for example, DIRECTORY_SEPARATOR
is \ - not /. This is an issue because the SFTP specs say that directories are to be represented with / - not . Quoting draft-ietf-secsh-filexfer-02:
This protocol represents file names as strings. File names are assumed to use the slash ('/') character as a directory separator.
I guess to have further insight a copy of the SFTP logs would be helpful. Maybe just provide the SFTP logs of a mkdir
operation. You can get the SFTP logs by doing define('NET_SFTP_LOGGING', 2)
at the top and then doing echo $sftp->getSFTPLog()
after the mkdir
.