1 回答

TA貢獻1844條經(jīng)驗 獲得超8個贊
您可以通過這種方式上傳多個文件
輸入字段必須定義為數(shù)組,即
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 關注
- 194 瀏覽
添加回答
舉報