Javascript and file upload not working as expected with click()
<p>I am creating a upload control in javascript and then using <code>element.click()</code> to bring up the file browser dialog. </p>

<pre><code>    function add(type) {            
        var element = document.createElement("input");
        element.setAttribute("type", type);
        element.setAttribute("value", type);
        element.setAttribute("name", type);            
        element.setAttribute("id", "element-" + i);
        var removebutton = document.createElement('a');
        var removeimage = document.createElement('img');
        removeimage.setAttribute("width", 15);
        removeimage.setAttribute("height", 15);
        removeimage.setAttribute("class", "removebutton");                                                
        removeimage.src = "/Content/Images/redx.png";            
        removebutton.appendChild(removeimage);
        removebutton.setAttribute("id", "remove-" + i);
        removebutton.setAttribute("onclick", "remove(" + i + "); return 0;");
        var newfile = document.getElementById("uploadhere");
        //newfile.appendChild(removebutton);
        newfile.appendChild(element);
        newfile.appendChild(removebutton);
        element.click();
        i++;                     
    }
</code></pre>

<p>The file broswer dialog comes up as intended but after I select the submit on my form any files entered into the control dissapear. </p>

<p>If I click the "browse" I get the file broswer dialog but the file uploads correctly. </p>

<p>How can I add a file upload control to my form and have it display the file broswer dialog and still work as intended. </p>
