简体   繁体   中英

PHP script dies before ftp_get() finishes downloading a file

I know how to download a file from a server using FTP with PHP.

I have a list of files to download from the ftp to an internal storage.

I use ftp_get() to download the list of files, the first file size is: 126 mb, successfully downloaded to my internal storage.

However the PHP function throws an error 500, and then dies without continuing.

The error I get:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@zzz.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Any idea what I should do in order for the function to complete its run successfully?

Maybe you exceeded the maximum execution time.

Try to increase it:
https://www.php.net/manual/en/function.set-time-limit.php

You need to increase the timeout then. 180 is in seconds, which is 3 minutes. Try setting it to 600. Ie: FTP_TIMEOUT_SEC, 600 or higher , depending on how much more time is needed. You probably could even try FTP_TIMEOUT_SEC, 0 which I think is NO time limit.

It is already commented for one more question similar to this. Please try this. It should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM