If you upload a large file, one of the more important php.ini settings is max_execution_time. To only change this setting for specific actions one could try to use set_time_limit() at the beginning of those actions that expect large $_POST data. But this will not work: The script will always time out, before the first line of code is run. So there’s no way to increase execution time from inside the script for large uploads.
Does anyone object to this? I just want to make sure i’m not overlooking something. So if someone disagrees, let me know.
One workaround i see, would be to use a .htaccess file with some php_value inside specific <Location> directives for the upload URL.
Yes, there are different settings that might need to be changed. Still it’s the same problem: You can’t change these settings inside your script, because that’s too late.
I don’t want this to affect all my scripts. Only those that really require e.g. more time for execution should get this privilege. There could be some error condition (e.g. problem with db connection) that causes lot of “zombie” processes to hang around for 300 seconds instead of killing them off soon after some short timeout. So i see this as one step in saving server ressources.
I see you point, Mike. I can be only sorry for you because I recall from my earlier projects (not too much in this area) that whenever script execution time problem appeared a really trouble were starting. Meaning that at least in my situation, using php.ini and functions related to script timeout never worked as supposed (see second point of this post as an example). I find myself this part of PHP the worst coded among all others!