#46485 [Bgs]: Problem uploading a file
| From: | lbarnaud@php.net | Date: | Tue, 04 Nov 2008 22:49:56 +0000 |
| Subject: | #46485 [Bgs]: Problem uploading a file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-130626@lists.php.net to get a copy of this message | ||
ID: 46485
Updated by: lbarnaud@php.net
Reported By: nyaka at nyaka dot com
Status: Bogus
Bug Type: Apache2 related
Operating System: Solaris 10
PHP Version: 5.2.6
New Comment:
The error code is set when the POST handler did not found the final
boundary in the client's input. This may happen when the boundary is
effectively missing, or e.g. when the Content-Length is incorrect.
Previous Comments:
------------------------------------------------------------------------
[2008-11-04 22:19:56] nyaka at nyaka dot com
Yes, it is exactly what happened - some part of your code thinks that
there is an error. So to summarize:
1. Custom application sends the file.
2. TCP dump shows the file is transferred.
3. Trace shows that the temporary file is created and data written to
it.
4. PHP deletes the temporary file.
5. PHP reports error 3 - (partial upload).
As I said, absolutely the same scenario works with previous versions of
Apache and PHP. So the file was transferred; why does PHP complain?
------------------------------------------------------------------------
[2008-11-04 22:01:33] lbarnaud@php.net
On error the temp file is deleted before the PHP script is executed.
When no error, the temp file is deleted after the PHP script is
executed.
Is this not what happens for you ?
------------------------------------------------------------------------
[2008-11-04 21:53:20] nyaka at nyaka dot com
I understand that POST handler deletes temporary file, but should it
delete if AFTER the actual php script is executed? The temporary file
cannot be accessed from the php script. It is visible from the trace I
provided and from dump of $_FILES variable.
------------------------------------------------------------------------
[2008-11-04 21:45:09] lbarnaud@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
> [error] => 3
On error, the POST handler deletes the temporary file.
Please see http://www.php.net/manual/en/features.file-upload.php
------------------------------------------------------------------------
[2008-11-04 21:35:14] nyaka at nyaka dot com
Description:
------------
I'm trying to upload a file with PHP 5.2.6 and Apache 2.2.9 from a
custom application. It worked for me previously with Apache 1.3 and PHP
4.3.
I also tried to use PHP 5.2.7RC3-dev (cli) (built: Nov 4 2008
20:43:51). Same results.
Reproduce code:
---------------
<?php
error_log(print_r($_FILES, TRUE));
?>
Expected result:
----------------
I expect the file to be uploaded and $_FILES array to contain correct
data about that file and not an error message.
Actual result:
--------------
This is from the apache error log:
Array
(
[wav] => Array
(
[name] => msg-94_48972.wav
[type] =>
[tmp_name] =>
[error] => 3
[size] => 0
)
)
This is trace of httpd with truss:
.......
8469: read(23, " P O S T / v o i c e m".., 8000) = 4344
8469: stat64("/share/web/snom/voicemail.php", 0x08047880) = 0
.......
8469: time() = 1225822869
8469: resolvepath("/tmp", "/tmp", 1024) = 4
8469: getpid() = 8469 [8463]
8469: lstat64("/tmp/phpjFaOIq", 0x08044800) Err#2 ENOENT
8469: open("/tmp/phpjFaOIq", O_RDWR|O_CREAT|O_EXCL, 0600) = 24
8469: write(24, " R I F F92 6\0\0 W A V E".., 5119) = 5119
8469: write(24, " nDCB895EA04 69A1C I n '".., 5119) = 5119
8469: read(23, " nD504 H8EE3C8 rCB\0B691".., 8000) = 2346
8469: write(24, " 2C4E215B9 aD6 <E6 J aD9".., 3779) = 3779
8469: close(24) = 0
8469: unlink("/tmp/phpjFaOIq") = 0
.......
8469: resolvepath("/share/web/snom/voicemail.php",
"/share/web/snom/voicemail.php", 1024) = 29
8469: open("/share/web/snom/voicemail.php", O_RDONLY) = 25
.......
I can see here that the temporary file is actually created and the data
is written to it. But after the file is closed an unlink is executed.
I can provide TCP dump if necessary.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46485&edit=1