php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73041 max_execution_time starts counting when file upload starts
Submitted: 2016-09-07 16:03 UTC Modified: 2016-09-08 11:44 UTC
From: mitenem at outlook dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.0.10 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mitenem at outlook dot com
New email:
PHP Version: OS:

 

 [2016-09-07 16:03 UTC] mitenem at outlook dot com
Description:
------------
When I try to upload file and upload takes more than max_execution_time, PHP returns fatal error maximum execution time was exceeded immediately after file is uploaded. Error is always thrown on line in which first <?php or <? appears.

I use Apache 2.4.23 with PHP 7.0.10 as an module (tested on systems with both 32-bit and both 64-bit).

Apache configuration for PHP in httpd.conf:
LoadModule php7_module [...]/php/php7apache2_4.dll
<FilesMatch \.php$>
  SetHandler application/x-httpd-php
</FilesMatch>

Various tested scenarios:
* max_execution_time = 30, max_input_time = -1
  * uploaded 200 kB file: upload took about 5 seconds, no errors, successfully uploaded
  * uploaded 3 MB file: upload took about 35 seconds, fatal error
  * uploaded 8 MB file: upload took about 90 seconds, fatal error
* max_execution_time = 30, max_input_time = 300
  * uploaded 200 kB file: upload took about 5 seconds, no errors, successfully uploaded
  * uploaded 3 MB file: upload took about 35 seconds, fatal error
  * uploaded 8 MB file: upload took about 90 seconds, fatal error
* max_execution_time = 300, max_input_time = 300
  * uploaded 200 kB file: upload took about 5 seconds, no errors, successfully uploaded
  * uploaded 3 MB file: upload took about 35 seconds, no errors, successfully uploaded
  * uploaded 8 MB file: upload took about 90 seconds, no errors, successfully uploaded

Script below was tested without php.ini file.
Values returned by ini_get:
max_execution_time = 30
max_input_time = -1

Test script:
---------------
<!DOCTYPE html>
<html>
<body>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data">
	<input type="file" name="file" />
	<input type="submit" />
</form>
<?php print_r($_FILES); ?>
</body>
</html>

Expected result:
----------------
File should be normally uploaded and $_FILES should contain its data.

Actual result:
--------------
Fatal error: Maximum execution time of 30 seconds exceeded in [...]\test.php on line 4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-08 11:44 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2016-09-08 11:44 UTC] ab@php.net
Thanks for the report. It is not a bug. Ensuring the timeout setting is high enough is the way to go. Turning off the time limit puts your site under security risk.

Thanks.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Dec 18 02:00:02 2025 UTC