Sean
Sean

Reputation: 269

PHP Transfer file from one FTP to another

Within my PHP script I need to transfer a file from one FTP site to another. I have found one way to do it but it times out due to the file being quite large. I have no control over the server so I can't increase the script execution time.

Therefore I was wondering if it is possible to send a request to the FTP site to copy the file over but then the PHP script continue executing leaving the copy happening in the background?

If there are any other suggestions that would solve my issue I would appreciate them.

Thanks in advance.

Upvotes: 0

Views: 1691

Answers (3)

user1467267
user1467267

Reputation:

If you have the control over your webserver's operating system it would be wisest to use the shell_exec() command and use your native system resources to initiate the FTP transfer.

This is will be a lot faster and more efficient in terms of system resources. As I don't know your OS I'll leave that up to you which commands to use the FTP transfers in the shell.

Upvotes: 1

Stanislav Saranchin
Stanislav Saranchin

Reputation: 58

Try FXP (http://en.wikipedia.org/wiki/File_eXchange_Protocol) to transfer files direct from server to server without transfering to/from client.

Upvotes: 0

Sammitch
Sammitch

Reputation: 32242

Use set_time_limit(0) at the top of your script, just be sure that you don't accidentally create any infinite loops in your code or you'll have to have shell access to kill all your zombie processes.

Upvotes: 0

Related Questions