1

If I try to upload a very large file in WordPress which is ~ 100 mb in file size, the max_execution_time in PHP is reached and I get a browser-styled error page which reads:

This webpage is not available

The connection to example.com was interrupted

Error code: ERR_CONNECTION_RESET

Is there a way I can detect when the execution time has been reached and display my own custom error message in place of the default error message I am getting?

henrywright
  • 10,070
  • 23
  • 89
  • 150

1 Answers1

0

Consider using PHP's set_time_limit() function when appropriate:

http://www.php.net/manual/en/function.set-time-limit.php

set_time_limit(0);
Denis de Bernardy
  • 75,850
  • 13
  • 131
  • 154
  • thanks for this! I'm wondering if it's a good idea to remove the time limit from a script? Couldn't that result in a performance issue - especially if people leave their browser window open? – henrywright Apr 30 '14 at 13:19
  • Well, not really, since the script *will* eventually end, and you don't want it to end with an error. If a user is uploading a 100MB file, I'd gather he'll be willing to wait until the server responds somehow. – Denis de Bernardy Apr 30 '14 at 13:22
  • Good point about the script eventually ending! I just tried `set_time_limit(0)` in my script and still got the error `ERR_CONNECTION_RESET` which makes me think this might not be due to PHP timing out? I'll need to investigate more. Thanks for your help – henrywright Apr 30 '14 at 14:00
  • Google it a bit more, I think. Perhaps it might be this or something else in SO already: http://stackoverflow.com/questions/21092681/err-connection-reset-in-multiple-browsers-on-multiple-networks – Denis de Bernardy Apr 30 '14 at 14:02