首先向大家介绍一下html5中file的multiple属性
定义和用法
multiple 属性规定输入字段可选择多个值。如果应用该属性,,则字段可接受多个值。
Select images:
上面实例中的input file 可接受多个文件上传字段。
领会了html5中file的multiple属性,下面我们开始解说应用html5实现多文件上传。
实例代码:
html:
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
}
}
}
感谢导语,愿望能赞助到大家,谢谢大家对本站的支持!