php 使用html5实现多文件上传实例

前端之家收集整理的这篇文章主要介绍了php 使用html5实现多文件上传实例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

定义和用法

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

实例:

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

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

实例代码

html:

<Meta charset="UTF-8">
PHP" method="post" enctype="multipart/form-data">

PHP代码

PHP;"> for($i=0; $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

}
}
}

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持

原文链接:https://www.f2er.com/php/18702.html

猜你在找的PHP相关文章