It is possible to upload multiple files simultaneously and have the information organized automatically in arrays for you. To do so, you need to use the same array submission syntax in the HTML form as you do with multiple selects and checkboxes:
Note: Support for multiple file uploads was added in version 3.0.10.
Example 19-2. Uploading multiple files
|
When the above form is submitted, the arrays $userfile, $userfile_name, and $userfile_size will be formed in the global scope (as well as in $HTTP_POST_FILES ($HTTP_POST_VARS in PHP 3)). Each of these will be a numerically indexed array of the appropriate values for the submitted files.
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.