ftp_put(): 命令 STOR 失败

ftp_put(): Command STOR failed

在我的 Laravel 应用程序中,我试图允许用户将基本文件上传到远程 FTP,并且我已经能够创建到我的 FTP 的连接通过 PHP 但是当我的代码遇到 ftp_put() 时它会抛出这个错误。

ftp_put(): Command STOR failed

我已经确认我可以通过 FileZilla 将文件上传到我的 FTP,它确实允许我这样做。任何形式的见解都会很棒。

下面是我目前使用的代码。

if (Input::hasFile('file')) {
        $path = Input::file('file')->getRealPath();

        $uploadpath = '/users/';

        $usr = 'login';
        $pwd = 'password';

        // file to move:
        $local_file = $path;
        $ftp_path = $uploadpath;

        // connect to FTP server
        $conn_id = ftp_connect('ftp.url.com');

        // send access parameters
        ftp_login($conn_id, $usr, $pwd);

        // turn on passive mode transfers (some servers need this)
        ftp_pasv ($conn_id, true);

        // perform file upload
        ftp_put($conn_id, $ftp_path, $local_file, FTP_ASCII);

        ftp_close($conn_id);
    }

找到解决方案!

我的上传路径只是路径本身,在我对上传路径进行附加以包含文件名后,它允许上传通过。

因此,如果有人在相同情况下遇到相同问题:

 $uploadpath = '/users/' . $file_name;
 $ftp_path = $uploadpath;