Hi
i created input type file elements dynamically by js
the elements are not parsing by php in post method.
if i removed the table tags around them, then its working. could anybody help me with this to go on.
just copy the code and run in wamp and resolve it. its really haunting me.
Thanks in advance. please spare time for me. thankyou.

the file name is test.php

<?php 
if ($_POST['Submit'] == 'Submit')
{
	print_r($_FILES) ;
}
	?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function addFileInput() {
 	var d = document.createElement("div");
 	var file = document.createElement("input");
 	file.setAttribute("type", "file");
 	file.setAttribute("name", "image[]");
 	//d.appendChild(file);
 	document.getElementById("moreUploads").appendChild(file); 	
}
</script>
</head>

<body>
</body>
<table width="95%" border="0" align="center" cellpadding="5" cellspacing="0" class="border_table">
			  <form name="f1" method="post" action="test.php" enctype="multipart/form-data" >               
                <tr>
                  <td align="right"><b>File 1 for image Upload</b></td>
                  <td align="left"><label id="moreUploads">				  
				  </label>
<div id="moreUploadsLink" ><a href="javascript:addFileInput();">Attach another File</a></div></td>
                </tr>
                
                <tr>
                  <td align="right"><br /></td>
                  <td align="left">by hitting submit, you agree to the websites terms and conditions</td>
                </tr>
                <tr>
                  <td align="right">&nbsp;</td>
                  <td align="left"><input name="Submit" type="submit" class="buttons" value="Submit" />
                      <input name="Reset" type="reset" class="buttons" value="Reset" /></td>
                </tr>
				</form>
              </table>
</html>

The form needs to surround the outside of the table. Below is a fixed up version:

<?php 
if ($_POST['Submit'] == 'Submit')
{
print_r($_FILES) ;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function addFileInput() {
var d = document.createElement("div");
var file = document.createElement("input");
file.setAttribute("type", "file");
file.setAttribute("name", "image[]");
//d.appendChild(file);
document.getElementById("moreUploads").appendChild(file); 
}
</script>
</head>

<body>
</body>
<form name="f1" method="post" action="test.php" enctype="multipart/form-data" > 
<table width="95%" border="0" align="center" cellpadding="5" cellspacing="0" class="border_table">
<tr>
<td align="right"><b>File 1 for image Upload</b></td>
<td align="left"><label id="moreUploads"> 
</label>
<div id="moreUploadsLink" ><a href="javascript:addFileInput();">Attach another File</a></div></td>
</tr>

<tr>
<td align="right"><br /></td>
<td align="left">by hitting submit, you agree to the websites terms and conditions</td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td align="left"><input name="Submit" type="submit" class="buttons" value="Submit" />
<input name="Reset" type="reset" class="buttons" value="Reset" /></td>
</tr>
</table>
</form>
</html>
This article has been dead for over six months. Start a new discussion instead.