Php multi-file Upload implementation instance _ php instance

Source: Internet
Author: User
In php, it is very easy to implement file upload. but if we want to upload multiple files at a time, how should we compile the code ?, If you need it, refer to the following section to explain the implementation methods.

To upload multiple files, add multiple input file fields to the form, and set the name attribute of these input files to the same name and use an array to name them, for example, filename []. Php code for file upload is the same as that for single file upload.

Here is an example of multifile upload:

HTML file example.html

 

Php file my_parser.php

<?phpif(isset($_FILES['file_array'])){  $name_array = $_FILES['file_array']['name'];  $tmp_name_array = $_FILES['file_array']['tmp_name'];  $type_array = $_FILES['file_array']['type'];  $size_array = $_FILES['file_array']['size'];  $error_array = $_FILES['file_array']['error'];  for($i = 0; $i < count($tmp_name_array); $i++){    if(move_uploaded_file($tmp_name_array[$i], "test_uploads/".$name_array[$i])){      echo $name_array[$i]." upload is complete
"; } else { echo "move_uploaded_file function failed for ".$name_array[$i]."
"; } }}?>

Thank you for reading this article. I hope it will help you. thank you for your support for this site!

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.