Php 通过表单发布图像数组
我有一个动态创建的div数组,每个div中都有图像,我想通过表单发布这些图像 目前我没有收到任何警报 添加了一个var_dump($_POST)并得到了这个结果Php 通过表单发布图像数组,php,javascript,html,forms,post,Php,Javascript,Html,Forms,Post,我有一个动态创建的div数组,每个div中都有图像,我想通过表单发布这些图像 目前我没有收到任何警报 添加了一个var_dump($_POST)并得到了这个结果 array(3) { ["imagename"]=> array(1) { [5]=> string(35) "upload_pic/thumbnail_1365064772.jpg" } ["id"]=> array(1)
array(3) {
["imagename"]=> array(1)
{
[5]=> string(35) "upload_pic/thumbnail_1365064772.jpg"
}
["id"]=> array(1)
{
[5]=> string(1) "5"
}
["box_type"]=> array(1)
{
[5]=> string(5) "image"
}
}
如何将其放入for循环中
任何帮助都将不胜感激
这是我的密码:
javascript:
function NewImgBox(imge, id)
{
id=id+i;
var new1div = document.createElement('div');
new1div.setAttribute('id', id);
new1div.setAttribute('class', 'dragbox');
new1div.setAttribute('iterate',i);
new1div.style.position = "relative";
new1div.style.top = p;
new1div.style.left = p;
new1div.style.cursor='move';
new1div.innerHTML = "</div><br><input type='image' value='"+i+"' disabled name='image["+i +"]' src='"+imge+"' id='"+i+"'class='image1' style='width:300px; height:300px;'>";
new1div.innerHTML=new1div.innerHTML+"<br><input type='hidden' value='"+imge+"' name='imagename["+i+"]'>";
new1div.innerHTML=new1div.innerHTML+"<br><input type='hidden' value='"+i+"' name='id["+i+"]'><br><input name='box_type["+i+"]' type='hidden' value='image'/>";
document.getElementById("frmMain").appendChild(new1div);
}
函数NewImgBox(imge,id)
{
id=id+i;
var new1div=document.createElement('div');
new1div.setAttribute('id',id);
new1div.setAttribute('class','dragbox');
new1div.setAttribute('iterate',i);
new1div.style.position=“相对”;
new1div.style.top=p;
new1div.style.left=p;
new1div.style.cursor='move';
new1div.innerHTML=“
”;
new1div.innerHTML=new1div.innerHTML+“
”;
new1div.innerHTML=new1div.innerHTML+“
”;
文件.getElementById(“frmMain”).appendChild(new1div);
}
html:
NewImgBox(“”,'draggable')
php:
if($\u服务器['REQUEST\u方法]]=“POST”)
{
foreach($\u POST['image']作为$j=>$value)
{
$imagename=$\u POST[“imagename”][$j];
$box\u type=$\u POST['box\u type'][$j];
$box\u id=$\u POST['id'][$j];
?>警报(“imagename=”);警报(“box_id=”);警报(“box_type=”);意识到for循环应该
foreach($_POST['imagename'] as $j => $value)
现在它开始工作了
if($_SERVER['REQUEST_METHOD'] == "POST")
{
foreach($_POST['image'] as $j => $value)
{
$imagename=$_POST["imagename"][$j];
$box_type=$_POST['box_type'][$j];
$box_id=$_POST['id'][$j];
?><script>alert("imagename=<? echo $imagename; ?>");</script><?
?><script>alert("box_id=<? echo $box_id; ?>");</script><?
?><script>alert("box_type=<? echo $box_type; ?>");</script><?
}
}
foreach($_POST['imagename'] as $j => $value)