Take input type=file without server

G

Guest

Hello,

this is been frustrating me all morning. Any help would greatly be appreciated

I have a site (not my own, not done in asp.net) that will be posting data to
my c# page. There is an input type=file in that form. How do I get the value?

All the examples I see online tell you to set your form up as runat=server
but tha won't work in this case since I won't be dealing directly with the
form, just the returned data. This is what I have, it fails because it cant
convert a string to an HtmlInputFile... thoughts?

HtmlInputFile filMyFile = (HtmlInputFile)Request.QueryString["uplTheFile"];
// Convert to HttpPostedFile?

HttpPostedFile myFile = filMyFile.PostedFile;
int nFileLen = myFile.ContentLength;
byte[] myData = new byte[nFileLen];
string fileName = myFile.FileName;
string strBaseLocation = "c:\web\upload";
myFile.InputStream.Read(myData, 0, nFileLen);
FileStream newFile = new FileStream(strBaseLocation+fileName,
FileMode.Create);
newFile.Write(myData , 0, myData.Length);
newFile.Close();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top