本文介绍了如何使用带有表单输入的子文件夹提交文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索很多,目前我对没有子文件夹的文件夹有答案:



我尝试了什么:



这是我的main.php页面,其中包含提交表格



< form action =uploadproject.phpmethod =POSTenctype =multipart / form-data> 
< input type =filename =archive []webkitdirectory multiple =>

< button type =submitname =submit> Upload< / button>
< / form>



这是我的uploadproject.php,我获取提交的文件夹并将其移至我的文件系统



 for($ i = 0; $ i< count($ _ FILES ['archive'] ['name']); $ i ++){
if ($ _FILES ['archive'] ['error'] [$ i] == 0){
move_uploaded_file($ _ FILES ['archive'] ['tmp_name'] [$ i],'uploads /'。
$ _FILES ['archive'] ['name'] [$ i]);
}
}



这样我基本上将所有文件夹内容上传到我的'uploads'文件夹。



如何将子文件夹上传到上传?

解决方案




I have been searching quite a lot, and I currently have an answer for folders without subfolders:

What I have tried:

Here's my main.php page with the submit form

<form action="uploadproject.php" method="POST" enctype="multipart/form-data">
    <input type="file" name="archive[]" webkitdirectory multiple="">

    <button type="submit" name="submit">Upload</button>
</form>


Here's my uploadproject.php, where I get the submitted folder and move it to my filesystem

for ($i=0; $i < count($_FILES['archive']['name']); $i++) {
    if ($_FILES['archive']['error'][$i]==0) {
        move_uploaded_file($_FILES['archive']['tmp_name'][$i], 'uploads/'.
            $_FILES['archive']['name'][$i]);
    }
}


This way I'm basically uploading all the folder contents into my 'uploads' folder.

How can I upload subfolders to 'uploads' as well?

解决方案




这篇关于如何使用带有表单输入的子文件夹提交文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 20:11