Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP configuration: max_execution_time and max_input_time

Tags:

php

Can I set the following PHP configuration parameters as follows:

max_execution_time = 360 max_input_time 360

Is that safe and efficient ?

I actually need my user to upload large videos with the php-based Content Management System.

So, each video upload takes some minutes. Do I need to change both and the values are good ?

thanks

like image 766
aneuryzm Avatar asked Sep 21 '10 08:09

aneuryzm


People also ask

What is the best value for max_execution_time in PHP?

max_execution_time is set to 60 which is too low. A minimum execution time of 150 seconds is recommended to give the migration process the best chance of succeeding.

What should max_execution_time be?

By default, the max_execution_time is usually set to 30 seconds. If your PHP scripts need more time, then you need to edit the value in the . htaccess file.

How do I increase PHP time limit?

PHP maximum execution time limit in php.Open php. ini file using your favorite text editor. Look for max_execution_time directive. Set the value for max_execution_time in seconds.


2 Answers

In my understanding, you have to change neither.

If you just store the video files using move_uploaded_file, you will not need to increase your max_execution_time as upload time does not count towards execution time.

The manual says the following about max_input_time (emphasis mine):

This sets the maximum time in seconds a script is allowed to parse input data, like POST, GET and file uploads.

I have not tested this, but to me this sounds like it doesn't include the actual time the client spends uploading the file, just the time it takes to copy it to the temporary directory. I can't vouch for this though, and I can't find any info on it. The default of 60 seconds should be ample time to parse many hundreds of megabytes of files.

I'd recommend to find out the perfect value using real-life tests. If your connection is too fast, use a tool to slow it down. See this SO question for suggestions:

Network tools that simulate slow network connection

like image 165
Pekka Avatar answered Oct 09 '22 14:10

Pekka


In my case, max_input_time does affect my move_uploaded_file function. I failed to upload a 3GB file with default setting (max_input_time=60) but it succeeded with a larger value (max_input_time=300).

My PHP version is 7.2.19 on LAMP enviroment.

like image 36
Liu Kc Avatar answered Oct 09 '22 13:10

Liu Kc