Php multi-file Upload implementation principle and code _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.