Php code for multifile upload-PHP Tutorial

Source: Internet
Author: User
Php implements multi-file upload program code. Php file upload is not much different from multifile Upload. multifile Upload only changes the form name to an array, with foreach traversal, you can upload multiple files. php file uploading is not much different from uploading multiple files. multifile Upload only changes the form name to an array, you can use foreach traversal to upload multiple files. for dynamic multi-file upload, you only need to add a dynamic multi-file upload box in js, in the same way, when processing in php, just traverse the array.

The simplest example is as follows:

The code is as follows:

Foreach ($ _ FILES ["pictures"] ["error"] as $ key => $ error ){
If ($ error = UPLOAD_ERR_ OK ){
$ Tmp_name = $ _ FILES ["pictures"] ["tmp_name"] [$ key];
$ Name = $ _ FILES ["pictures"] ["name"] [$ key];
Move_uploaded_file ($ tmp_name, "data/$ name ");
}
}
?>

The following is an example of other friends.
Example 1

The code is as follows:

// Filename: multi_upload.php
If ($ ifupload)
{
$ Path = AddSlashes (dirname ($ PATH_TRANSLATED). "upload ";
For ($ I = 1; $ I <= 8; $ I ++)
{
$ Files = "afile". $ I;
If ($ {$ files }! = "None ")
{
If (copy ($ {$ files}, $ path. $ {$ files. "_ name "}))
{
}
}
}
Print"You have uploaded files successfully
";
Print "Return ";
Exit;
}
?>





Upload multiple files

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.