File is not uploading to FTP and errors: Warning: ftp_put() [function.ftp-put]: Can't open that file: No such file or directory coming. We are using following code:
$server = 'ftp.domain.com';
$ftp_user_name = '[email protected]';
$ftp_user_pass = 'password';
$dest = 'files/test.txt';
$source = 'test.txt';
$src = ini_get("upload_tmp_dir");
$connection = ftp_connect($server);
$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);
if (!$connection || !$login) { die('Connection attempt failed!'); }
$upload = ftp_put($connection, $dest, $source, FTP_BINARY);
if (!$upload) { echo 'FTP upload failed!'; }
ftp_close($connection);
Your firewall could be blocking it. Ensure you have the IP address in your welcome email for hostname (only the numbers; don't add FTP, www, or anything else). Make sure your username and password are the same as your control panel username and password. Some FTP programs require a path to connect.
Answer: There is not a limit on the size of the file. But keep in mind that the bigger the file the longer it will take to be transferred. However, either a ReadTimeout or OutOfMemory message may appear, depending on how many files are on the ftp server, and how large the files are.
FTP upload and download speed depend mainly on the client's connection to the server. This may be affected by multiple network factors such as hop count and local connectivity. Also, there are other factors which may affect the speed: The number of clients that currently are using the FTP service.
Here's an answer from the comments of php.net on ftp_put:
Found the prob, you can't put a path to the destination file (even though I can do that in the dos ftp client...?)
e.g. - this doesn't work
ftp_put($conn, '/www/site/file.html','c:/wamp/www/site/file.html',FTP_BINARY);
you have to put
ftp_chdir($conn, '/www/site/');
ftp_put($conn,'file.html', 'c:/wamp/www/site/file.html', FTP_BINARY );
http://php.net/manual/en/function.ftp-put.php
I had same problem and I solved it using ftp_nb_put(). Same function but it allows your program to run more connections or something:-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With