我使用的是phpstudy哈
在php.ini里面配置.
注意一下,这里,斜杠要写对
upload_tmp_dir代表你的临时目录在哪里哈。这里写不对,就没有效果的哈.
我的在这里
新建一个upload在
F:\6\htdocs下
核心在于,多文件因为多,所以需要是数组,所以遍历即可
1.html
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <form action="2.php" method="POST" enctype="multipart/form-data"> <!--<input type="hidden" name="MAX_FILE_SIZE" value="30000" />--> Send this file: <input name="file[]" type="file" /> Send this file: <input name="file[]" type="file" /> <input type="submit" value="提交" /> </form> </script> </body> </html>
2.php
<?php foreach($_FILES as $file){ $fileNum=count($file['name']); for ($i=0; $i < $fileNum; $i++) { echo move_uploaded_file($_FILES['file']['tmp_name'][$i],'F:/6/htdocs/upload/'.basename($_FILES['file']['name'][$i])); //意思是吧f:6/tmp/图片放到upload里面哈, } }