Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ftp_put working for month, now has stopped?

Tags:

php

upload

ftp

Hi have the below syntax:

$source = $csv_filename;  
$target = '/locexport/'.$csv_filename;
$conn = ftp_connect("ftp.server.com") or die("Could not connect");
ftp_login($conn, "ftpusername", "ftppassword");

ftp_pasv($conn, false); 

$upload = ftp_put($conn, $target, $source, FTP_ASCII);
if (!$upload) { echo 'FTP upload failed!'; }

This script runs with cron jobs every few hours and has worked for months.

it has suddenly stopped working.

echoing $source and $destination shows the correct paths.

error message is:

Warning: ftp_put() [function.ftp-put]: Opening ASCII mode data connection. in /home/shareduser/public_html/export/export.php on line 55
FTP upload failed!

line 55 is:

 $upload = ftp_put($conn, $target, $source, FTP_ASCII);

I have tried changing FTP_ASCII to FTP_BINARY but with the same result.

any ides how to troubleshoot this? it is not a permission issue as a manual transfer in Filezilla with the same credentials succeeds.

Thanks and Regards.

like image 355
JustStarting Avatar asked Jan 18 '26 16:01

JustStarting


1 Answers

You could try to switch to passive mode (set it to true):

ftp_pasv($conn, true);

Maybe something has changed in destination's firewall.

like image 134
Mihai Iorga Avatar answered Jan 20 '26 08:01

Mihai Iorga



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!