Php multi-file Upload implementation code. Index_uploads.php copy code is as follows: htmlheadmetacharsetutf-8titleindex_uploadstitleheadbodyformactionuploads.phpmethodpostenctypemultipartform-data 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.
The http://www.bkjia.com/PHPjc/825278.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/825278.htmlTechArticleindex_uploads.php code is as follows: html head meta charset = "UTF-8" titleindex_uploads/title/head body form action = "uploads. php "method =" post "enctype =" multipart/form-data...