|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9460 File upload problem when the form control name is an array element
Submitted: 2001-02-26 08:01 UTC Modified: 2001-10-28 16:56 UTC
From: robin at planet-three dot net Assigned:
Status: Closed Package: HTTP related
PHP Version: 4.0.4pl1 OS: Suse (2.2.16 kernel)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: robin at planet-three dot net
New email:
PHP Version: OS:


 [2001-02-26 08:01 UTC] robin at planet-three dot net
I was trying to submit a form divided into sections, each
section having a two text fields and a file upload. The
form was structured as an array called $section, each
element an array containing firstname, surname and image.

The image details I expected to turn up in $HTTP_POST_FILES as $HTTP_POST_FILES[section][0][name] etc. That behaved as

The other form elements I expected to turn up as
$HTTP_POST_VARS[section][0][firstname] etc. However
what I ended up with was $HTTP_POST_VARS[section][0]
being set to the filesize of the uploaded file, overwriting
all other elements in that section.

// ---------------start upload.php--------------------------
print "<pre>\nVars:\n";
print "\nFiles:\n"; 
print "</pre>\n";

<form method='post' enctype='multipart/form-data'>
   <input type='text' name='section[0][firstname]'> <br>
   <input type='text' name='section[0][surname]'> <br>
   <input type='file' name='section[0][image]'> <br> 
   <input type='submit'>
// ---------------end upload.php----------------------------

// ---------------start input ------------------------------
  section[0][firstname] = foo
  section[0][surname]   = bar
  section[0][image]     = ~/feathers.gif
// ---------------end input --------------------------------

// ---------------start output -----------------------------

    [section] => Array
            [0] => 12409


    [section] => Array
            [0] => Array
                    [name] => Array
                            [image] => feathers.gif

                    [type] => Array
                            [image] => image/gif

                    [tmp_name] => Array
                            [image] => /tmp/phpwwJSPf

                    [size] => Array
                            [image] => 12409




// ---------------end output -------------------------------



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-28 16:56 UTC]
Works fine with latest CVS.


 [2003-07-02 11:58 UTC] marc at osknowledge dot org
The problem appears with PHP 4.2.3 on Mandrake, too. I have not MDK kernel or glibc installed but the PHP RPMS are the one delivered with MDK 9.0 I think. I have no chance to test a PHP 4.3 install, sorry.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 28 20:01:31 2024 UTC