简体   繁体   English

PHP脚本在ftp_get()完成下载文件之前终止

[英]PHP script dies before ftp_get() finishes downloading a file

I know how to download a file from a server using FTP with PHP. 我知道如何使用FTP和PHP从服务器下载文件。

I have a list of files to download from the ftp to an internal storage. 我有要从ftp下载到内部存储器的文件列表。

I use ftp_get() to download the list of files, the first file size is: 126 mb, successfully downloaded to my internal storage. 我使用ftp_get()下载文件列表,第一个文件大小为:126 mb,已成功下载到我的内部存储中。

However the PHP function throws an error 500, and then dies without continuing. 但是,PHP函数抛出错误500,然后死而没有继续。

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. 请与服务器管理员webmaster@zzz.com联系,并通知他们错误发生的时间,以及您可能做的任何可能导致错误的事情。

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. 此外,尝试使用ErrorDocument处理请求时遇到404 Not Found错误。

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 https://www.php.net/manual/zh/function.set-time-limit.php

You need to increase the timeout then. 您需要增加超时时间。 180 is in seconds, which is 3 minutes. 180秒(即3分钟)。 Try setting it to 600. Ie: FTP_TIMEOUT_SEC, 600 or higher , depending on how much more time is needed. 尝试将其设置为600。即: FTP_TIMEOUT_SEC, 600 or higher ,具体取决于需要多少时间。 You probably could even try FTP_TIMEOUT_SEC, 0 which I think is NO time limit. 您甚至可以尝试FTP_TIMEOUT_SEC, 0 ,我认为没有时间限制。

It is already commented for one more question similar to this. 已经对此提出了另一个类似问题的评论。 Please try this. 请尝试这个。 It should work. 它应该工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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