php 使用html5实现多文件上传

首先向大家介绍一下html5中file的multiple属性

定义和用法

multiple 属性规定输入字段可选择多个值。如果使用该属性,则字段可接受多个值。

实例:

Select images:

上面实例中的input file可接受多个文件上传字段。

了解了html5中file的multiple属性,下面我们开始讲解使用html5实现多文件上传

实例代码

html:

<Meta charset="UTF-8">

PHP" method="post" enctype="multipart/form-data">

PHP代码

for($i=0; $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 = "./uploadFiles/" . $_FILES['upload']['name'][$i];

//Upload the file into the temp dir

if(move_uploaded_file($tmpFilePath,$newFilePath)) {

//Handle other code here

}

}

}

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...