duanaoreng9355 2017-02-16 08:51
浏览 30
已采纳

PHP move_uploaded_file用于上传的目录

I'm developing an app that should upload with a for a directory to the server, I've alredy change the configuration for the max upload size in the php.iniindeed the upload is done correctly. I know the function move_uploaded_file to "store" a single file uploaded but my question is there is a way to use it for a directory uploaded?

This is my code:

HTML:

<form action="upload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="files[]" id="files" multiple="" directory="" webkitdirectory="" mozdirectory="">
    <input class="button" type="submit" value="Upload" />
</form>

PHP:

if (isset($_POST["submit"])) {
    if ($_FILES["file"]["error"] > 0) {
    } else {
        $storagename = $_FILES["file"]["name"];
        move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $storagename);
    }
}
$a= scandir("upload");
print_r($a);

With this code the result of the print is this:

Array ( [0] => . [1] => .. )

How can solve it?

Thank's

  • 写回答

1条回答 默认 最新

  • dscqrkvr9562034621 2017-02-16 09:00
    关注

    You have to iterate the $_FILES["file"]["name"].

    I think this post can help you: How to upload folder with PHP?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料