您当前的位置: 首页 >  php

暂无认证

  • 1浏览

    0关注

    95081博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

php多文件上传(教你用最少的代码实现):

发布时间:2022-03-10 11:48:59 ,浏览量:1

我使用的是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

 $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里面哈, } } 

在这里插入图片描述

关注
打赏
1655516835
查看更多评论
立即登录/注册

微信扫码登录

0.0492s