1 回答

TA贡献1844条经验 获得超8个赞
您可以通过这种方式上传多个文件
输入字段必须定义为数组,即
images[]
它应该定义为
multiple="multiple"
<input name="images[]" type="file" multiple="multiple" />
// Count # of uploaded files in array
$total = count($_FILES['images']['name']);
// Loop through each file
for( $i=0 ; $i < $total ; $i++ ) {
//Get the temp file path
$tmpFilePath = $_FILES['images']['tmp_name'][$i];
//Make sure we have a file path
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "./uploadFiles/" . $_FILES['images']['name'][$i];
//Upload the file into the temp dir
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
//Handle other code here
}
}
}
有关更多详细信息,PHP多次上传
- 1 回答
- 0 关注
- 182 浏览
添加回答
举报