c# - How to capture file upload data from web page external to an ASP.NET site using .NET -


I know how to get the file from the client using standard ASP.NET techniques, however, I Data needs to be retrieved from a third party web page written in basic HTML and ASP.Net can process file data in web application.

So if the original HTML looks like this ...

& Lt; Input type = "submit" value = "click" /> & Lt; / Form & gt;

How do I obtain file data in the page referring to the action attribute of the form? So far, I have tried the following code, which allows me to use the filename - but there is no byte stream of the file.

  Secure Zero Page_load (Object Sender, EventArgs E) {string fileName = Request.form ["fileUpload1"]; // no files appear in the request. The collection of files in the code below. Forward (string file files in request) {HttpPostedFile HPF = Request. Files [File] as HTML posted file; If (hpf.ContentLength == 0) continues; String savedFileName = Path.Combine (AppDomain.CurrentDomain.Base directory, path.getFileName (hpf.FileName)); Hpf.SaveAs (savedFileName);   

Your form is incorrect enctype should be on the parameter form tag:

  & lt; Form id = "form1" action = "WebForm.aspx" method = "post" encrypt = "multipart / form-data" & gt; & Lt; Input name = "fileUpload1" type = "file" /> & Lt; Input type = "submit" value = "click" / & gt; & Lt; / Form & gt;  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -