PHP using HTML5 to implement multiple file upload instance _php instance

Source: Internet
Author: User
Tags php code

First, let's introduce the multiple property of file in HTML5

Definitions and usage

The multiple property stipulates that the input field can select multiple values. If this property is used, the field can accept multiple values.

Instance:

<form action= "demo_form.asp" method= "get" >
 Select Images: <input type= "file" Name= "img" multiple= " Multiple "/>
 <input type=" Submit "/>
</form>

The input file in the above instance can accept multiple file upload fields.

Understanding the multiple attribute of the file in HTML5, we begin by explaining how to use HTML5 to implement multiple file uploads.

Instance code:

Html:

<! DOCTYPE html>
 
 

PHP Code:

For ($i =0 $i <count ($_files[' upload '] [' name ']) $i + +) {
 //get the temp file path
 $tmpFilePath = $_files[' Upload ' [' tmp_name '] [$i];

 Make sure we have a filepath
 if ($tmpFilePath!= "") {
  //setup our new file path
  $newFilePath = "./uploadfile s/". $_files[' upload ' [' name '] [$i];

  Upload the "file into" temp dir
  if (Move_uploaded_file ($tmpFilePath, $newFilePath)) {

   //handle other code her E

  }
 }
}

Thank you for reading, I hope to 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.