A
A
Alex Ivanov2018-04-10 13:13:22
PHP
Alex Ivanov, 2018-04-10 13:13:22

How to identify a problem with an FTP upload?

Good afternoon, the second day I toil with a problem - there is a server (file hosting) to which I can upload only via FTP. Everything seems to be nothing, there is a working script that, in the decodarray array cycle, logs in to the server, uploads the file and disconnects.

$file_name  = '/var/www/www-root/data/www/domain.com/images/'.trim($decodarray[$i]['fname']);
$ftp_file    = trim($decodarray[$i]['fname']);

$ftp = ftp_connect($ftp_server, $ftp_port, 20);
ftp_login($ftp, $ftp_user_name, $ftp_user_pass);

ftp_pasv($ftp, true); 
if(!ftp_fput($ftp, $ftp_file, $file_name, FTP_BINARY)){
 echo "ERROR";
}
ftp_close($ftp);

The script has been tested many times, but on this server it works somehow strangely - it only uploads 30% of all files. At the same time, there is no dependence on the file size - it gives an error both for small (20Mb) and for files up to 1gigabyte. Due to the fact that the function only returns true or false, I can’t understand the reason and fix it. What are the options for solving the problem?
And, yes, ... in the logs, of course, everything is clean :( I
ran it under SSH. and oh, miracle ....
when there are no messages, the file is poured, and when the warning " PHP Warning: ftp_put(): type set ." or " PHP Warning: ftp_put(): Opening ASCII mode data connection " then the file is not being uploaded. what's the nonsense? The transfer type is set explicitly. how can it change in asks?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2018-04-10
@Protossan

use Kurl,
especially imbued with his timebars

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question