I’m using the upload form below to post to a page that processes the file using the code below. However, the file isn’t showing up. I get count 0 with no files posted…. Am I missing something in the form post? I know it’s fairly specific as to what must be used when files are uploaded. I’ve included further info below as well.
Form
<form id="importform" method="POST" target="uploadframe" enctype="multipart/form-data" action="AJAX/Import_Subprocess_Content/RAC_Connolly_ImportSession.aspx">
<input type="file" id="importfile" onchange="fileselected()"/>
<input type="button" value="Import File" onclick="uploadfile();" />
</form>
Server-Side Code
protected void Page_Load()
{
Response.Write(Request.Files.Count);
}
Further Information
The form is posted via javascript using .submit()
The file input is visibility:hidden
the button first calls the click() of the file input
onchange the file input calls the submit() of the form
UPDATE: Tried removing the hidden attribute, but it did not correct the issue.
File required a name attribute to be uploaded. When given the name attribute, another problem arises with IE7, the inability to post forms via javascript when uploading files. Had to default to using submit button rather than onchange event.