php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55450 Built in web server not accepting file uploads
Submitted: 2011-08-18 14:19 UTC Modified: 2011-08-19 11:55 UTC
From: scott at aubrey dot org dot uk Assigned: laruence (profile)
Status: Closed Package: Built-in web server
PHP Version: 5.4.0alpha3 OS: Mac OS X 10.7.1 (Lion )
Private report: No CVE-ID: None
 [2011-08-18 14:19 UTC] scott at aubrey dot org dot uk
Description:
------------
The built in web server does not handle file uploads, instead throwing an error.

This is a fairly clean build of alpha 3.

Test script:
---------------
<?php
var_dump($_SERVER);
?>

<form enctype="multipart/form-data" method="post">
    <label for="filename">Select a file to upload:</label><br>
    <input type="file" id="file" name="file">
    <br><br>
    <input type="submit" name="action" value="Upload">
</form>

Expected result:
----------------
array(1) { ["file"]=> array(5) { ["name"]=> string(7) "testupload.txt" ["type"]=> 
string(10) "text/plain" ["tmp_name"]=> string(26) "/private/var/tmp/phpynOZom" 
["error"]=> int(0) ["size"]=> int(12) } } 

Actual result:
--------------
array(0) { } 


--
Error log throws:


PHP Warning:  Missing boundary in multipart/form-data POST data in Unknown on 
line 0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-18 14:22 UTC] scott at aubrey dot org dot uk
forgot to add, that I started the server with:
php -nS localhost:8001 -t.

and the server output was: 

[Thu Aug 18 15:13:56 2011] ::1:54367 GET /testUpload.php - Request read
[Thu Aug 18 15:13:56 2011] ::1:54367 GET /testUpload.php - Response sent successfully (200)
[Thu Aug 18 15:14:01 2011] ::1:54369 POST /testUpload.php - Request read
[Thu Aug 18 15:14:01 2011] ::1:54369 POST /testUpload.php - Response sent successfully (200)
 [2011-08-18 14:42 UTC] johannes@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: moriyoshi
 [2011-08-19 06:37 UTC] laruence@php.net
this should due to the following code in sapi/cli/php_cli_server.c 2161 : 
php_cli_server_client_populate_request_info:

...
 {
        char **val;
        const char delimiter[] = ";";
        if (SUCCESS == zend_hash_find(&client->request.headers, "Content-Type", 
sizeof("Content-Type"), (void**)&val)) {
            request_info->content_type = strtok(*val, delimiter);
        }
    }
...

which erased the boundary content of "multipart/form-data; boundary=----****",
 [2011-08-19 08:30 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=315162
Log: Fixed #55450 (Built in web server not accepting file uploads), which might break #55121 fixing(r313677)
Reopened #55121 to let somebody redone the fixing(as I can't reproduce 55121 in redhat 64-bit).
 [2011-08-19 08:52 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=315164
Log: News for bug #55450
 [2011-08-19 11:55 UTC] laruence@php.net
-Status: Assigned +Status: Closed -Assigned To: moriyoshi +Assigned To: laruence
 [2011-08-19 11:55 UTC] laruence@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2012-04-18 09:49 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7790c4d975084cf99a6cbd0cc6308caf8c2232b7
Log: Fixed #55450 (Built in web server not accepting file uploads), which might break #55121 fixing(r313677) Reopened #55121 to let somebody redone the fixing(as I can't reproduce 55121 in redhat 64-bit).
 [2012-07-24 23:40 UTC] rasmus@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7790c4d975084cf99a6cbd0cc6308caf8c2232b7
Log: Fixed #55450 (Built in web server not accepting file uploads), which might break #55121 fixing(r313677) Reopened #55121 to let somebody redone the fixing(as I can't reproduce 55121 in redhat 64-bit).
 [2013-11-17 09:36 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=7790c4d975084cf99a6cbd0cc6308caf8c2232b7
Log: Fixed #55450 (Built in web server not accepting file uploads), which might break #55121 fixing(r313677) Reopened #55121 to let somebody redone the fixing(as I can't reproduce 55121 in redhat 64-bit).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC