From:             [EMAIL PROTECTED]
Operating system: Redhat 7.3
PHP version:      4.2.3
PHP Bug Type:     Variables related
Bug description:  _FILES unintuitive when arrays used.

PHP seems to mix up array-based file uploads.  In the
simple example code I've attached, pick any two files,
and you'll get an array that looks like this:

$_FILES =

[thing]=> Array
(
  [name][test]     => ...
  [type][test]     => ...
  [tmp_name][test] => ...
  [error][test]    => ...
  [size][test]     => ...
)
[other] => Array
(
  [name]     => ...
  [type]     => ...
  [tmp_name] => ...
  [error]    => ...
  [size]     => ...
)

But you'd expect from how the last array works, that the
elements: name, type, tmp_name, error, size, are associated
with the actual uploaded file.  In that case, you'd expect:

[thing]=> Array
(
  [test] => Array
  (
    [name]     => ...
    [type]     => ...
    [tmp_name] => ...
    [error]    => ...
    [size]     => ...
  )
)
[other] => Array
(
  [name]     => ...
  [type]     => ...
  [tmp_name] => ...
  [error]    => ...
  [size]     => ...
)

This makes the $_FILES variable virtually impossible to
use in a foreach or while context, as all of the
associated elements are not associated with the array
elements, but vice versa.

This is also the crux of the problem that caused $_FILES
to be removed from $_REQUEST in CVS.  Since, if I have an
element named stuff[name] in a form upload, and a file
called stuff[thing], then the $_REQUEST variable would
contain stuff[name][thing] when it should be 
stuff[thing][name] and stuff[name] as separate elements.

------------------- Attached Code -------------------
<form method="post"
      action="<?PHP print $_SERVER['PHP_SELF']; ?>"
      enctype="MULTIPART/FORM-DATA">
  <input type="file" name="thing[test]">
  <input type="file" name="other">
  <input type="submit" value="Submit">
</form>

<pre>
<?PHP print_r($_FILES); ?>
</pre>
------------------- Attached Code -------------------

-- 
Edit bug report at http://bugs.php.net/?id=20402&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=20402&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=20402&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=20402&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=20402&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=20402&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=20402&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=20402&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=20402&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=20402&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=20402&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20402&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=20402&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=20402&r=isapi

Reply via email to