c# - How to process a file upload in ASP.NET with a form that does NOT have runat="server"? -


for reasons beyond question, cannot have form on page runat="server" attribute.

how go accessing uploaded file uploaded using regular <input type="file"...?

this question touches on issue, (using <input type="file" rather <asp:fileupload), still both runat=server.

the types of things able acheive (server side, after form has been posted), include:

  • if (myinput.hasfile) ...
  • var filename = myinput.filename;
  • var fullpathandfile = myinput.postedfile.filename;
  • var mimetype = myinput.postedfile.contenttype;

i'm sure of stuff can done, i'm used .net taking care of of me!

update: after insightful comments below, seem doing things in odd manner...

i looking along lines of:

httppostedfile file = request.files["myfile"]; //accessing file without having element being runat="server", e.g. manually through request. //(i know doesn't work without runat="server", example clarify question)  //if(myfile.hasfile) ... if (file != null && file.contentlength) ...  //var fname = myfile.filename var fname = path.getfilename(file.filename); 

but seems requires runat="server"

this question seems little confused.

first off, mean having form on page? asp.net pages should have one form (with or without runat="server").

this wording makes me think have issue should addressed first. it's extremely unusual have valid reason more 1 form on asp.net page.

but if need, remove asp.net tags question , replace them html have nothing asp.net.


Comments