4条回答 默认 最新
- 斯洛文尼亚旅游 2018-10-16 01:51关注
名字改为数组形式
<form action="" method="post" enctype="multipart/form-data"> Send these files:<br /> <input name="upload[]" type="file" multiple /><br /> <input type="submit" value="Send files" /> </form> <?php print_r($_FILES["upload"]); ?>
保存文件
// Count # of uploaded files in array $total = count($_FILES['upload']['name']); // Loop through each file for($i=0; $i<$total; $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 } } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报