|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-11-15 15:43 UTC] felipe@php.net
-Status: Open
+Status: Feedback
[2011-11-15 15:43 UTC] felipe@php.net
[2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 23:00:02 2025 UTC |
Description: ------------ This bug is very specific to Windows. When executing a generic file upload using PHP, if at anytime while the file is being uploaded Apache then runs a CGI script like PERL or a C program, and the upload ends while the CGI script is still running, the uploaded file(s) in the temp directory will remain behind forever. In order to avoid this the “php_do_open_temporary_file” routine will have to not use the “VCWD_OPEN_MODE” routine to open the temp file. A generic Windows “open” call allows child processes to inherit their handles. The temp file would need to be opened with a “CreateFile” call to open the file and specify the pSecurityAttributes option with bInheritHandle set to FALSE so that a child process will not inherit the open file handle. The rub is this call uses a non-compatible handle so everyone who uses this handle has to be modified as well. Test script: --------------- Write or use any simple PHP upload program. Next use CGI program below -- it doesn't need to do anything except take time. So start the PHP upload, then start the CGI program below from a webpage. Make sure the PHP upload completes before the script ends. #include <windows.h> void main(){ Sleep(2*60*1000); // sleep 2 minutes } Expected result: ---------------- The file should be uploaded and the temp file in the temp directory should not be present when done. It should be moved to the destination directory. Actual result: -------------- The temp file remains forever in the temp directory, though the file is copied correctly to the destination directory.