php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #12060 $userfile['name'][0] not set !
Submitted: 2001-07-11 12:40 UTC Modified: 2002-01-28 06:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: afortaleza at yahoo dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0.6 OS: Linux 2.4.5
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: afortaleza at yahoo dot com
New email:
PHP Version: OS:

 

 [2001-07-11 12:40 UTC] afortaleza at yahoo dot com
http://www.php.net/manual/en/features.file-upload.multiple.php 
says that:

"For instance, assume that the filenames 
/home/test/review.html and /home/test/xwp.out are 
submitted. In this case, $userfile_name[0] would contain 
the value review.html, and $userfile_name[1] would contain 
the value xwp.out. Similarly, $userfile_size[0] would 
contain review.html's filesize, and so forth. 

$userfile['name'][0], $userfile['tmp_name'][0], 
$userfile['size'][0], and $userfile['type'][0] are also 
set. "

But they are not set !

Here's the script that requites 2 pages, form.html and 
file-upload.php

form.php
========
<html>
<head></head>
<body>
<form action="file-upload.php" method="post" 
enctype="multipart/form-data">
  Send these files:<br>
  <input name="userfile[]" type="file"><br>
  <input name="userfile[]" type="file"><br>
  <input type="submit" value="Send files">
</form>
</body>
</html>

file-upload.php
===============
<?php
// We will not upload, just show the variables
print_r ( $HTTP_POST_FILES );
print_r ( $userfile );
?>

You will notice that $userfile is a one dimensional array 
that contains only the names of the temporary files 
uploaded.

My PHP is:
==========
./configure

Anderson Fortaleza

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-11 14:00 UTC] jeroen@php.net
Should be $userfile[0]['name']!

Do a var_dump() on userfile to check it out.

doc-TODO: add example in the docs about this.
 [2002-01-27 17:49 UTC] biteme at scream dot com
This doesn't appear to be a Documentation bug. I don't get anything but first level in the array, which is the temporary file name....

Uploading 5 files, with the tag:

<input name="files[]" type="file"><br>

a vardump($files) shows me:
array(5) { 
           [0]=>  string(38)
               "/usr/local/data/PhotoUploads/php5LPZGT" 
           [1]=>  string(38)
               "/usr/local/data/PhotoUploads/phpqVsa8A"
           [2]=>  string(4) 
               "none" 
           [3]=>  string(4) 
               "none" 
           [4]=>  string(4) 
               "none" 
         } 

This may have been fixed in a newer version, but 4.0.6 is the latest RPM you can get for a RedHat 7 system. If it's fixed in a future version, I'd like to know, before I go through the trouble of a non-rpm update to find out. (:

-= Jay =-
 [2002-01-28 02:52 UTC] biteme at scream dot com
Ok, so I went through all the trouble to make my own RPM for the update to 4.1.1. This bug is still there, $userfile is a 1 dimensional array. Not the multi-dimensional array the docs say it's supposed to be.

-= Jay =-
 [2002-01-28 05:56 UTC] derick@php.net
The new file uploading mechanism is only available in php 4.2.0 and higher (which is not yet released).

Derick
 [2002-01-28 06:22 UTC] yohgaki@php.net
Fixed.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 09:01:28 2025 UTC