我需要帮助来解决如何使用input type textbox
动态创建多个文件夹?
我只能在文件夹中创建单个动态子目录,但是当显示多个输入类型文本框时我想要多个子文件夹?
问题是我只能使用输入类型文本框
在文件夹中创建一个子目录我已经使用javascript创建了多个文本框?
Php代码
//creating a folder
$folder = implode($_POST['folder']);
for($i=0; $i<$folder; $i++)
{
$dirPath = 'uploads/'.$folder.[$i];
$result = mkdir($dirPath);
}
的Javascript
<script type="text/javascript">
var i = 0;
function changeIt(){
i++;
var table=document.getElementById("itemdetail");
var row=table.insertRow();
var cell1=row.insertCell();
cell1.innerHTML="<input type='text' name='folder[]' id=folder_"+i+"'/>";
}
</script>
表格
<form method="post" enctype="multipart/form-data">
<input type="text" name="folder[]" id="folder_0" /><br />
//dynamically creating textbox into table row
<table id="itemdetail"></table>
<input type="button" n="addnewitem" id="addnewitem"
value="Add New Question" onClick="changeIt()"/>
</form>
例如
input type value is test1 ... uploads/subdirectory = test1
input type value is test2 ... uploads/subdirectory = test2
input type value is test3 ... uploads/subdirectory = test3
答案 0 :(得分:0)
你可以试试这个,
if(isset($_POST)){
$folders = $_POST['folder'];
foreach($folders as $folder){
$dirPath = 'uploads/'.$folder;
$result = mkdir($dirPath);
}
}