This article mainly introduces php multi-File Upload implementation code. For more information, see index_uploads.php.
The Code is as follows:
Index_uploads
Uploads. php
The Code is as follows:
Header ("content-type: text/html; charset = UTF-8 ");
Echo"
";
print_r($_FILES);
echo "
";
$ Count = count ($ _ FILES ['file'] ['name']);
For ($ I = 0; $ I <$ count; $ I ++ ){
$ Tmpfile = $ _ FILES ['file'] ['tmp _ name'] [$ I];
$ Filefix = array_pop (explode (".", $ _ FILES ['file'] ['name'] [$ I]);
$ Dstfile = "uploads/files/". time (). "_". mt_rand (). ".". $ filefix;
If (move_uploaded_file ($ tmpfile, $ dstfile )){
Echo "script" alert ('succeed! '); Window. location. href = 'index _ uploads. php'; script ";
} Else {
Echo "script alert ('fail! '); Window. location. href = 'index _ uploads. php'; script ";
}
}
Core: <1> the name attribute of input in the upload homepage is set in this way.
<2> Use A while LOOP to upload multiple files.