How to increase transaction timeout? I want to upload videos, but large size of videos not uploaded?
It throws error The process *** exceeded the timeout of 60 seconds.
You need to change some settings in your php.ini:
upload_max_filesize = 2M
;or whatever size you want
max_execution_time = 60
; also, higher if you must - sets the maximum time in seconds
Where your PHP.ini is located depends on your system environment. For more information: http://php.net/manual/en/ini.list.php
You should be able to do during runtime too using
set_time_limit(100);
http://php.net/manual/en/function.set-time-limit.php
or in your vhost-config
php_admin_value max_execution_time 10000
Having a global execution time limit that is LOW is mostly a good idea for performance-reasons on not-so-reliable applications. So you might want to only allow those scripts to run longer that absolutely have to.
p.s.: Dont forget about post_max_size and upload_max_filesize (like the first answer told allready)
To complete the answer of Hannes.
You need to change some setting in your php.ini:
upload_max_filesize = 2M
;or whatever size you want
max_execution_time = 60
; also, higher if you must
If someone want put in unlimited (I don't know why but if you want), you can set the time to 0:
You need to change some setting in your php.ini:
upload_max_filesize = 0
max_execution_time = 0
And if you don't know where is your php.ini. You can do a file "name.php" in your server and put:
<?php phpinfo(); ?>
And on your website, you can see the config of your php.ini and it's marked where is it.
Edit on 9 January 2015:
If you can't access your php.ini, you have two more options.
You can set this line directly in your "name.php" file but I don't find for upload_max_filesize for this option:
set_time_limit(0);
Or in ".htaccess"
php_value upload_max_filesize 0
php_value max_execution_time 0
if what you need to do is specific only for 1 or 2 pages i suggest to use set_time_limit so it did not affect the whole application.
set_time_limit(some_values);
but ofcourse these 2 values (post_max_size & upload_max_filesize) are subject to investigate.
you either can set it via ini_set function
ini_set('post_max_size','20M');
ini_set('upload_max_filesize','2M');
or directly in php.ini file like response above by Hannes, or even set it iin .htaccess like below
php_value upload_max_filesize 2M
php_value post_max_size 20M
If you happen to be using Microsoft IIS server, in addition to the php.ini settings mentioned by others, you may need to increase the execution timeout settings for the PHP FastCGI application in the IIS Server Manager:
Step 1) Open the IIS Server Manager (usually under Server Manager in the Start Menu, then Tools / Internet Information Services (IIS) Manager).
Step 2) Click on the main connection (not specific to any particular domain).
Step 3) Under the IIS section, find FastCGI Settings (shown below).
Step 4) Therein, right-click the PHP application and select Edit....
Step 5) Check the timeouts (shown below).
In my case, the default timeouts here were 70 and 90 seconds; the former of which was causing a 500 Internal Server Error on PHP scripts that took longer than 70 seconds.
As an addition to above answers, you may use set_time_limit() function:
http://php.net/manual/en/function.set-time-limit.php
passing 0 as an argument will make your script run with no time limit.
If you cannot edit php.ini (on your server for example) you can attempt to change the php.ini parameters from within your php code. Try:
ini_set('max_execution_time', 'NUMBER OF SECONDS TO ALLOW BEFORE TIMEOUT');
If that doesn't work, try also setting 'set_time_limit' in the same way, beyond that I'd say your only option is to contact your host. These settings cannot be modified while in safe mode.
You had a typo: ini_set('max_input_time','200M') - value set needs to be an int, like ini_set('max_input_time','200')
I know you are specifically asking about the PHP timeout, but what no one else seems to have mentioned is that there can also be a timeout on the webserver and it can look very similar to the PHP timeout.
So if you have tried:
Increasing the timeout in php.ini by adding a line: max_execution_time = {number of seconds i.e. 60 for one minute}
Increasing the timeout in your script itself by adding: ini_set('max_execution_time','{number of seconds i.e. 60 for one minute}');
And you have checked with the phpinfo() function that max_execution_time has indeed be increased, then you might want to try adding this to .htaccess which will make sure Apache itself does not time out:
RewriteRule .* - [E=noabort:1]
RewriteRule .* - [E=noconntimeout:1]
More info here:
https://www.antropy.co.uk/blog/php-script-keeps-timing-out-despite-ini-set/
First check the php.ini file path by phpinfo(); and then changed PHP.INI params:
upload_max_filesize = 1000M
memory_limit = 1500M
post_max_size = 1500M
max_execution_time = 30
restarted Apache
set_time_limit(0); // safe_mode is off
ini_set('max_execution_time', 500); //500 seconds
Note: you can also use command to find php.ini in Linux
locate `php.ini`
Test if you are is safe mode - if not - set the time limit (Local Value) to what you want:
if(!ini_get('safe_mode')){
echo "safe mode off";
set_time_limit(180);// seconds
phpinfo();// see 'max_execution_time'
}
*You cannot set time limit this way if safe mode 'on'.
optional : if you set config about php.ini but still can't upload
-this is php function to check error code
$error_type = [];
$error_type[0] = "There is no error";
$error_type[1] = "The uploaded file exceeds the upload_max_filesize directive in php.ini.";
$error_type[2] = "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.";
$error_type[3] = "The uploaded file was only partially uploaded.";
$error_type[4] = "No file was uploaded.";
//$error_type["5"] = "";
$error_type[6] = "Missing a temporary folder. Introduced in PHP 5.0.3.";
$error_type[7] = "Failed to write file to disk. Introduced in PHP 5.1.0.";
$error_type[8] = "A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help. Introduced in PHP 5.2.0.";
//------------------------------
//--> show msg error.
$status_code = $_FILES["uploadfile"]["error"];
if($status_code != 0){
echo $error_type[$status_code];
exit;
}
You can also set a max execution time in your .htaccess file:
php_value max_execution_time 180
To really increase the time limit i prefer to first get the current value. set_time_limit is not always increasing the time limit. If the current value (e.g. from php.ini or formerly set) is higher than the value used in current call of set_time_limit, it will decrease the time limit!
So what's with a small helper like this?
/**
* #param int $seconds Time in seconds
* #return bool
*/
function increase_time_limit(int $seconds): bool
{
return set_time_limit(max(
ini_get('max_execution_time'), $seconds
));
}
// somewhere else in your code
increase_time_limit(180);
See also: Get max_execution_time in PHP script
I have read other answers here on stackoverflow, however this is a really weird issue.
My phpinfo() shows that I have set 512M for the post_max_size (I have also increased other properties to at least 512M)
However when I am trying to send post request from Angular HTTP to Laravel 5.2 api, I get 422 Unprocessed Entitym and php_error says:
PHP Warning: Unknown: POST Content-Length of 7323588 bytes exceeds the limit of 3145728 bytes in Unknown on line 0
I have changed both php.ini files,despite only one being loaded.
Step 1: Go to the folder destination where you have installed WAMP. (Usually it is C:)
Step 2: Now locate and open php.ini files from both these locations. (C:\wamp\bin\apache\Apache2.4.4\bin and C:\wamp\bin\php\php5.4.16)
Step 3: Now in both the documents press CTRL+F and find out the following settings.
post_max_size
upload_max_filesize
memory_limit
For example you will see upload_max_filesize = 2m where m is MB. Change 2m to 500m or more as you like.
Change post_max_size = 8m to post_max_size = 700m or more. Change memory_limit = 8m to memory_limit = 1000m.
Other than that to avoid fatal errors like maximum time of something exceeded in line something, find and change the following values.
max_execution_time = 30 to to max_execution_time = 3000 and max_input_time = 60 to 3000.
This was an interesting problem.
The issue was following:
Yes, I needed to change the post_max_size, however at one point in my php.ini I had it set to 1000M.
My Apache 2.4.9 , and PHP 5.5.12 decided to ignore the suffix M and I ended up with a limit of 1000 Bytes.
My solution was to set post_max_size = 1000000 to have the limit set to 1MB
On my site, I'm allowing file uploads. I've successfully uploaded a 40 MB file.
But I've been trying to upload a file above 40 mb
In my php.ini, I have the following:
upload_max_filesize = 10G
post_max_size = 10G
max_execution_time = 60
max_input_time = 10000
memory_limit = -1
I work on window server.
I tried a 100mb file. It failed every time.
Instead of
post_max_size = 10G
Try this
upload_max_filesize = 40M
Don't use too big size 10G ,Try with 100M
Are you using php > 5.1. The G modifier is available since PHP 5.1.0.
I think your php doesn't correctly parse the G you are using.
Try:
upload_max_filesize = 10000M
post_max_size = 10000M
Are you sure you want to allow 10 gigabyte? Better to define something close to the max file size you are using. So if it is something like 40 megabyte use 50M.
In php.ini I have set:
post_max_size = 101M
upload_max_filesize = 101M
memory_limit = 128M
a php upload form uses can upload file up to 100M
a script will check if it doesn't exceed 100M
$img_size = $_FILES['bestand']['size'];
if ($img_size > MAX_EXTRA_FILE_FILE_SIZE){
$errors['tooBig'] = 1;
However, if a user uploads 125M, the server returns the message:
PHP Warning: POST Content-Length of ########### bytes exceeds the limit of ...
and the $error['tooBig'] will lose its value and no error message
will be returned to the user. Of course, i can just increase the ini.php:post_max_size endlessly, but even than a use could upload even larger files.
How do i tackle this?
i'd like to know whats wring with my php.ini because I cant attach any file more than 200kb. I've already modified the upload_max_filesize and my post_max_size but still nothing happens. I'm using xampp, localhost and php mail() function. Every comment will be much very appreciated. thank you
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 20M
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20
; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = 40M
Many time upload_max_filesize didn't work on windows (xampp and wamp) . I recommend to switch to LAMP Or if you have to upload database you can use MYSQL workbench on windows system .