开发者

Script randomly cuts off

I've made a VERY basic website which takes an array of image URLs, zips them, and returns the zip location. The problem is that the script cuts off at some point.

One of the following usually happens:

  • not all the pictures are copied
  • not all pictures are copied and the last picture has 0 file size
  • sometimes the开发者_JAVA技巧 ajax call doesn't run the error or success callback

Is this because the server is only allowing a certain amount of time for the script to execute? It does seem to work with less pictures. What can I do?

I have the following settings:

max_execution_time 10 10 max_file_uploads 20 20 max_input_nesting_level 64 64 max_input_time 10

also, set_time_limit is disabled.

I tried ini_set('max_execution_time', 300); and nothing changed

edit: Probably a REALLY stupid question, but would it change anything if I executed another PHP page after a certain amount of time if the script isn't going to finish before the limit?


We could do with looking at your code, but if it is simply a case of the script timing out, you can use this line:

set_time_limit(0);

...to remove the time limit, and allow the script to execute completely in it's own time. You should call this as soon as you have validated the request, before you start the image copy/zip process.

If you post some code in the question I will update my answer further.


There are two things you can try:

  1. Increase the execution time limit with set_time_limit.
  2. Run the script through php.exe (as a console script) and not through a web server; in this scenario, there is no time limit by default.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜