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?

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

报告相同问题?

悬赏问题

  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错