Ok, I have an in template function that get's submitted via method="POST". But I can't submit this normally, since this is all I want submitted, and there is already a tag defined above the code and than below the code, closing the form with that must remain there. Since, there is no way to have forms inside of forms, I am using Javascript to create a form and submit it on the fly. But I need to get a copy of the file input element defined in the document.forms.creator form. I am using PHP and Javascript to accomplish what I have now, but the cloneNode(true) isn't getting the $_FILES['image'] array and setting it to the $_FILES['sigImg'] array :(
echo '<tr><td colspan="2"><a href="#" name="sig' . $user_info['id'] . '"></a><center><b>Signature Image Rotator</b></center><br /><center>
Add Image: <input type="file" size="48" id="imagefile" name="image" /> <input type="button" value="Upload" onclick="createFormAndSubmit()"></center>';
echo '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
//helper function to create the form
function getNewSubmitForm(){
var submitForm = document.createElement("FORM");
document.body.appendChild(submitForm);
submitForm.enctype = "multipart/form-data";
submitForm.method = "POST";
return submitForm;
}
//function that creates the form, clones <input type="file" name="image">,
//and then submits it
function createFormAndSubmit(){
var submitForm = getNewSubmitForm();
var element = document.getElementById("imagefile");
element = element.cloneNode(true);
element.id = \'sigImgId\'; //<- ID Assignment
element.name = \'sigImg\'; //<- NAME Assignment
submitForm.appendChild(element);
submitForm.action= "', $scripturl, '?action=sigimages;sa=upload";
submitForm.submit();
}
// ]]></script></td></tr>';
How can I get a real clone of the file input defined in the php echo and place it into the form defined in the createFormAndSubmit() function??
Please, somebody help...