imarinoff

Hi all, I need some help with dynamically building a form

i have the following code:

Code Snippet

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<script>
function upload(fileinputfield){
var newForm = document.createElement("form");
newForm.setAttribute("method", "post", 0);
newForm.setAttribute("id", "uploadfileform", 0);
newForm.setAttribute("enctype", "multipart/form-data", 0);
newForm.setAttribute("action", 'test2.php');
newForm.setAttribute("target","formsubmitframe", 0);
newForm.appendChild(fileinputfield);
document.getElementById("formdiv").appendChild(newForm);

var newIframe = document.createElement("iframe");
newIframe.setAttribute("id","formsubmitframe", 0);
newIframe.setAttribute("name","formsubmitframe", 0);
newIframe.setAttribute("src","about:blank", 0);
newIframe.setAttribute("frameborder",1, 0);
newIframe.setAttribute("width",300, 0);
newIframe.setAttribute("height",300, 0);
document.getElementById("iframediv").appendChild(newIframe);
newForm.submit();
}
</script>
</head>

<body>
<div id="formdiv"></div>
<div id="iframediv"></div>
<input onchange="upload(this)" type="file" id="" name="test">


</body>
</html>




And the test2.php is simple:

Code Snippet

<pre>< print_r($_POST) ></pre>
<pre>< print_r($_FILES) ></pre>



IE problems:

1. The form does not submits in the frame although there is a target specified
2. $_POST has the entry [test] => 'the path to file' and $_FILES is empty although there is enctype specified

No problems with Firefox

Please help

thanks