Forum Moderators: coopster

Message Too Old, No Replies

ftp_put stops working after uploading several hundred files

         

robur

7:12 pm on Jan 21, 2006 (gmt 0)

10+ Year Member



I have written a command line utility to keep my site synchronized using php. I do all the testing on my local computer, then run the script and it mirrors it to my remote site. It works perfectly, except that the ftp_put function stops working after uploading several hundred files.

Eventually, it stops working and displays errors like "Warning: ftp_put(): PORT command successful", and "Warning: ftp_put(): Could not open data connection to port 61613: Connection refused".

I am running php V 4 on Mac OS X.3.9, and have tried activating passive mode with the same results.

Does anyone have any ideas that might make this work?

-Robur

if (!ftp_put($GLOBALS['ftpc'], $to, $from, FTP_BINARY)) $GLOBALS['copyErrors'] += 1;

coopster

10:07 pm on Feb 2, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, robur.

I wonder if you aren't reaching a time limit or something. Try

set_time_limit [php.net](0);

robur

4:21 am on Feb 3, 2006 (gmt 0)

10+ Year Member



I have already tried that...

I am not sure, but port # 61613 sounds high to me.

Could it be possible that the ftp functions just keep eating up ports till the webserver runs out - if so, how to fix it?

-Robur

coopster

8:23 pm on Feb 4, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You aren't looping and opening a new connection each time, are you? Connect, login, transfer files, close. If you are looping, it should only be on the transfer portion of this process.

FalseDawn

9:06 pm on Feb 4, 2006 (gmt 0)

10+ Year Member



I've always found FTP transfers to be horribly slow and unreliable when transferring a large number of smaller files.

Now I simply create a compressed tarball of the appropriate directory, using tar and gzip for windows, copy that 1 file across, then uncompress and untar on the server, and chown and chmod as required.

Loads faster and more reliable.

robur

12:06 am on Feb 6, 2006 (gmt 0)

10+ Year Member



Coopster:

At the beginning of my script I open an ftp connection, store it in a global variable, use it for the rest of the script.

False Dawn:

That sounds like a good idea. I think it requires uploading a temporary php file to the remote site with an exec command inside it, then calling it with fopen(), then deleting it again. The only disadvantage is that the whole transfer has to start over if it gets interrupted. I will think about it...