Reputation: 470
In my Laravel application I'm trying to allow the user to upload basic files to a remote FTP and I've been able to create a connection to my FTP through PHP but the moment my code hits the ftp_put() it throws this error.
ftp_put(): Command STOR failed
I've verified that I am able to upload files to my FTP through FileZilla and it does let me do that. Any sort of insight would be awesome.
And below is the code I am using at the moment.
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);
}
Upvotes: 2
Views: 2520
Reputation: 470
Found the solution!
My upload path was just the path itself, after I made an appends to the upload path to include the file name as well it let the upload through.
So if anyone happens upon this same issue in the same circumstances:
$uploadpath = '/users/' . $file_name;
$ftp_path = $uploadpath;
Upvotes: 2