微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

}

}

}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐