本文介绍了在For循环中使用多个输入类型文本框动态创建多个子目录到文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我需要帮助解决如何使用输入类型文本框动态创建多个文件夹? i可以创建只有一个动态子目录到文件夹,但我想要多个子文件夹时多显示输入类型的文本框? 问题是,我可以创建只有一个使用输入类型的文本框时,文件夹中的子目录 我已经使用javascript创建了多个文本框? $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $夹']); ($ i = 0; $ i $一世]; $ result = mkdir($ dirPath); $ b Javascript < script type =text / javascript> var i = 0; 函数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 =postenctype =multipart / form-data> < input type =textname =folder []id =folder_0/>< br /> //动态创建文本框到表格行< table id =itemdetail>< / table> $ b $< input type =buttonn =addnewitemid =addnewitem value =添加新问题onClick =changeIt()/> < / form> 举例 输入类型值是test1 ... uploads / subdirectory = test1 输入类型值是test2 ... uploads / subdirectory = test2 输入类型值是test3 ... uploads / subdirectory = test3 解决方案试试这个, pre $ code> if(isset($ _ POST)){ $ folders = $ _POST [ '夹']; foreach($文件夹作为$文件夹){ $ dirPath ='uploads /'.$文件夹; $ result = mkdir($ dirPath); } } i need help to solve how to create dynamically multiple folders using input type textbox?i can create only single dynamically subdirectory into the folder but i want to multiple subfolder when multiple input type textbox are display?problem is that i can create only one subdirectory into the folder at time using input type textboxesi have already create multiple textbox using javascript?Php Code//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<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>For Exampleinput type value is test1 ... uploads/subdirectory = test1input type value is test2 ... uploads/subdirectory = test2input type value is test3 ... uploads/subdirectory = test3 解决方案 You can try this, if(isset($_POST)){ $folders = $_POST['folder']; foreach($folders as $folder){ $dirPath = 'uploads/'.$folder; $result = mkdir($dirPath); } } 这篇关于在For循环中使用多个输入类型文本框动态创建多个子目录到文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-18 05:14
查看更多