Php multi-file Upload implementation principle and code. The upload page, that is, inputtypef has a small research on the multi-image upload function today, and sorts out the following code to facilitate future use and communication.
1、upload.html page, that is, the file with input type = file:
The code is as follows:
2. do_upload.php page, that is, the page for processing multifile uploads:
The code is as follows:
// Global Array $ _ FILES
// $ _ FILES ['userfile'] ['tmp _ name'] location where the file is temporarily stored on the web server
// $ _ FILES ['userfile'] ['name'] file name in the user's system
// $ _ FILES ['userfile'] ['size'] file size in bytes
// $ _ FILES ['userfile'] ['type'] MIME type, text/plain, image/gif
// $ _ FILES ['userfile'] ['error'] error code related to file Upload
?>
// Use the for loop to obtain the transmitted data, which is a three-dimensional data.
For ($ I = 0; $ I
{
$ Upfile = $ new_folder. "/". $ _ FILES ['userfile'] ['name'] [$ I]; // you can modify it as needed.
If (move_uploaded_file ($ _ FILES ['userfile'] ['tmp _ name'] [$ I], $ upfile )){
Echo "". ($ I + 1). "The image is uploaded successfully.
";
}
Else {
Echo "no." ($ I + 1). "the image cannot be uploaded.
";
}
}
?>
When 1、upload.html page, that is, input type = f...