Upload a whole directory through an HTML form

后端 未结 8 2044
不思量自难忘°
不思量自难忘° 2020-11-28 12:47

Is it possible to upload a folder with a file input in the browser?

I searched and found out that this might be a browser limitation and that I might need to use a J

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-28 13:42

    Please Try This for upload the folder :

    `

    $count = 0;
    if ($_SERVER['REQUEST_METHOD'] == 'POST'){
        foreach ($_FILES['files']['name'] as $i => $name) {
            if (strlen($_FILES['files']['name'][$i]) > 1) {
                if (move_uploaded_file($_FILES['files']['tmp_name'][$i], 'folder/'.$name)) {
                    $count++;
                }
            }
        }
    }
    

    `

提交回复
热议问题