PHP supports uploading multiple files at the same time and automatically organizing their information in the form of an array. To do this, you need to use the same array submission syntax for the file upload fields in the HTML form as the multiple marquee and checkbox.
<title> multiple file uploads </title>
<link rel= "stylesheet" type= "text/css Tutorial" href= "My.css" >
<body>
<form action= "upload_array.php tutorial" method= "POST name=" Upload_multifiles "enctype=" Multipart/form-data ">
Please select File: <br>
<input type= "FILE" name= "userfile[" "size=" > <br>
<input type= "FILE" name= "userfile[" "size=" > <br>
<input type= "FILE" name= "userfile[" "size=" > <br>
<input type= "FILE" name= "userfile[" "size=" > <br>
<input type= "FILE" name= "userfile[" "size=" > <br>
<input type= "Submit" name= "Submit" value= "Start uploading" >
</FORM>
When the above form is submitted, the array $_files[' userfile '],$_files[' userfile ' [' name '] and $_files[' userfile '] [' size '] will be initialized (the previous version of the PHP 4.1.0 is $ Http_post_files). If Register_globals is set to ON, the global variables associated with the file upload will also be initialized. All of these submitted information will be stored in an array indexed by numbers.
For example, if a file named/home/test/review.html and/home/test/xwp.out is committed, the value of the $_files[' userfile ' [' name '][0] will be review.html, and $_files [' UserFile '] [' Name '] The value of [1] will be xwp.out. Similarly, $_files[' userfile ' [' Size '][0] will contain the size of the file review.html, and so on.
In addition, $_files[' UserFile ' [' Name '][0],$_files[' userfile '] [' tmp_name '][0],$_files[' userfile '] [' size '][0] and $_ files[' userfile ' [' type '][0].
PHP files
upload_array.php
--------------------------------
<?php
for ($i = 0; $i <count ($userfile); $i + +)
{
if ($userfile _ name[$i] <> "")//To determine whether the uploaded file is empty
{
copy ($userfile [$i], $userfile _name[$i]);
echo "filename: ", $userfile _name[$i], "<br> ";
echo "File size: ", $userfile _size[$i], "<br > ";
echo "file type: ", $userfile _type[$i];
}
}
?