Implementation example of PHP multi-file Upload

Source: Internet
Author: User
Tags upload php
First of all, explain the implementation of the method.

To implement multiple file uploads, we can add multiple input file fields to the form form and then set the Name property of the input file to the same name and use the form of an array named, for example, filename[]. As for the file upload PHP code and a single file upload is the same reason.

Here's an example of a multi-file upload:

HTML file example.html

<! DOCTYPE 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<br>";    } else {      echo "move_uploaded_file Function failed for ". $name _array[$i]." <br> ";    }}  }? >

Thank you for reading, hope to help everyone, thank you for the support of this site!

More PHP Multi-file Upload implementation Examples related articles please pay attention to topic.alibabacloud.com!

  • 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.