Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload file to FTP server in PHP

Tags:

php

ftp

My Code is to Upload file to FTP

 $conn_id = ftp_ssl_connect($ftp_server, 4480);
 $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
 ftp_pasv($conn_id, true);
 $upload = ftp_put($conn_id, "serverfile.txt", $file, FTP_BINARY);

Its giving this error

PHP Warning:  ftp_nb_put(): php_connect_nonb() failed: Operation now in progress (115) in /home/nanobi/PHP/ftp.php on line 51
PHP Warning:  ftp_nb_put(): Type set to I in /home/nanobi/PHP/ftp.php

Please help me to solve this

like image 944
Prasad Avatar asked Dec 30 '25 21:12

Prasad


1 Answers

I think you might be experiencing Bug #55651: Option to force PHP to ignore the PASV address returned. There's an issue when an FTP server behind a NAT device returns its local address in response to the PASV command. There's been a patch submitted for this issue years ago, but it hasn't made it into the source yet.

If your FTP server is behind a NAT device, try another FTP client for PHP and see if the issue persists.

like image 192
Roy Hvaara Avatar answered Jan 01 '26 10:01

Roy Hvaara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!