php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15681 File uploads causes PHP to consume too much CPU time
Submitted: 2002-02-22 15:01 UTC Modified: 2002-02-25 09:18 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: WPinegar at healthtech dot net Assigned:
Status: Closed Package: IIS related
PHP Version: 4.1.1 OS: Windows 2000 Server
Private report: No CVE-ID: None
 [2002-02-22 15:01 UTC] WPinegar at healthtech dot net
If I upload a large file to a PHP web page I noticed the upload consumes 100% of the cpu on the IIS server.  It sounds like there is a very small buffer being allocated in PHP for the file writing.  Is there any way to adjust this so that PHP can accept large HTML POSTs without consuming so much CPU time?

Attached is php code that will allow you to duplicate the problem:

----------------------------------

<HTML>
<TITLE>
File upload
</title>
<body>

<B>File upload</b>

<form enctype="multipart/form-data" action="upload.aspx" method="post">

<!-- "MAX_FILE_SIZE" determines the biggest size an uploaded
file can occupy -->

<input type="hidden" name="MAX_FILE_SIZE"
value="500000000">
Send this file: 
  <input id="File1" name="File1" type="file"><br><br>
<input type="submit" name="submit" value="Send
File">
</form>

</body>

<?PHP

/*  

$userfile - The temporary filename in which the uploaded file was stored
on the server machine. 

$userfile_name - The original name or path of the file on the sender's
system. 

$userfile_size - The size of the uploaded file in bytes. 

$userfile_type - The mime type of the file if the browser provided this
information. An example would be "image/gif". 
  
*/

// copy to this directory

$dir="c:\\Uploads\\";

  
// copy the file to the server

if (isset($submit)){

	copy($userfile,$dir.$userfile_name);	
	
	if (!is_uploaded_file ($userfile)){
	
		echo " <b>$userfile_name</b> couldn't be copied
!!";
	}
}

// check whether it has been uploaded

if (is_uploaded_file ($userfile)){

	echo " <b>$userfile_name</b> copied succesfully
!!";
	
}

?>

</html>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-23 01:02 UTC] sniper@php.net
This is already taken care of in CVS and the fix
will be in PHP 4.2 release. (And no, I don't know when
it will be released..)

You could try getting some dev build from www.php4win.de
though.

--Jani

 [2002-02-25 09:18 UTC] WPinegar at healthtech dot net
Yes, I downloaded and compiled the latest developers build of PHP 4.2.0 and this problem is indeed fixed.  Thanks!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 03:01:32 2024 UTC