php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #27456 file upload with arrays loses $_POST vars
Submitted: 2004-03-02 03:39 UTC Modified: 2004-03-02 12:26 UTC
From: php at humbapa dot ch Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.5RC3 OS: apache 2.0.48 @ Linux 2.6.2
Private report: No CVE-ID: None
 [2004-03-02 03:39 UTC] php at humbapa dot ch
Description:
------------
when I use a form with all input-fields named e.g. "foo[]" the fields after an input-file-field will be lost in the $_POST var.

Reproduce code:
---------------
<html>
   <head></head>
   <body>
      <form method="post" enctype="multipart/form-data" action="<?= $_SERVER['PHP_SELF'] ?>">
         <input name="foo[]" type="text"><br>
         <input name="foo[]" type="file"><br>
         <input name="foo[]" type="file"><br>
         <input name="foo[]" type="text"><br>
         <input type="submit" value="go"><br>
      </form>
      <pre>
<?
if (count($_POST)>0) {
   print_r($_POST);
   print_r($_FILES);
}
?>
      </pre>
   </body>
</html>

Expected result:
----------------
Array
(
    [foo] => Array
        (
            [0] => bar1
            [1] => bar2
        )

)
Array
(
    [foo] => Array
        (
            [name] => Array
                (
                    [0] => file1
                    [1] => file2
                )
...SKIP...

Actual result:
--------------
Array
(
    [foo] => Array
        (
            [0] => bar1
        )

)
Array
(
    [foo] => Array
        (
            [name] => Array
                (
                    [0] => file1
                    [1] => file2
                )
...SKIP...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-02 04:14 UTC] derick@php.net
You can not mix normal input fields and file upload fields in the same variable. Reclassified as documentation problem.
 [2004-03-02 12:26 UTC] sean@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

added the following to features.file-upload:

A developer may not mix normal input fields and file upload fields in the same form variable (by using an input name like foo[]).

S

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 07:01:34 2024 UTC