Reputation: 917
I'm trying to upload large files to my server (my server support post_max_size
192mb and max_execution_time
600 sec). When I upload 100mb files execution will stop after 600 sec so files are not uploaded to the server. How can I increase max_execution_time
in PHP (only for the file uploading process)? I have tried:
ini_set ( 'max_execution_time', 1200);
if(move_uploaded_file($_FILES['Video']['tmp_name'],$tmppath)) {
// ...
}
Any ideas how I can overcome this?
Upvotes: 23
Views: 217035
Reputation: 273
// Karvy master upload module
function uploadKarvyData()
{
ini_set('MAX_EXECUTION_TIME', -1);
ini_set('memory_limit', '-1');
or
ini_set( 'memory_limit', '1024M' );
ini_set('upload_max_filesize', '1024M');
ini_set('max_input_time', 360000);
ini_set('max_execution_time', 360000);
}
Upvotes: 0
Reputation: 24549
Add this to an htaccess file (and see edit notes added below):
<IfModule mod_php5.c>
php_value post_max_size 200M
php_value upload_max_filesize 200M
php_value memory_limit 300M
php_value max_execution_time 259200
php_value max_input_time 259200
php_value session.gc_maxlifetime 1200
</IfModule>
Additional resources and information:
2021 EDIT:
As PHP and Apache evolve and grow, I think it is important for me to take a moment to mention a few things to consider and possible "gotchas" to consider:
<IfModule
is loaded.mod_php5.c
in the first line. If you are using PHP 7, you would replace that with mod_php7.c
.php.ini
config file(s). This method is usually only useful in the event your hosting provider does not give you access to change those files. In circumstances where you can edit the PHP configuration, it is recommended that you apply these settings there.Upvotes: 39
Reputation: 4425
Is very easy, this work for me:
PHP:
set_time_limit(300); // Time in seconds, max_execution_time
Here is the PHP documentation
Upvotes: 2
Reputation: 2325
For increasing execution time and file size, you need to mention below values in your .htaccess file. It will work.
php_value upload_max_filesize 80M
php_value post_max_size 80M
php_value max_input_time 18000
php_value max_execution_time 18000
Upvotes: 0
Reputation: 14782
Theres a setting max_input_time
(on Apache) for many webservers that defines how long they will wait for post data, regardless of the size. If this time runs out the connection is closed without even touching the php.
So your problem is not necessarily solvable with php only but you will need to change the server settings too.
Upvotes: 6