1

This is probably something blatantly obvious that I'm just missing. Help me, SO! I'm trying to access file data submitted via POST from a web form (not the built in C# ones though.) I have no idea how to do this, and MSDN is singularly unhelpful in this matter.

Here's the three things I've tried so far:

Request["file"]; Request.Form["file"]; Request; 

What else is there? It just seems to be a missing POST data. If it helps, here's the output from firebug:

Content-Type: multipart/form-data; boundary=---------------------------149243018821763 Content-Length: 703 -----------------------------149243018821763 Content-Disposition: form-data; name="file"; filename="testsearch.txt" Content-Type: text/plain Just some plain text data. -----------------------------149243018821763 Content-Disposition: form-data; name="folder" ftp://wwwdev.jbu.edu/athletics/resource/media/testsearch.txt -----------------------------149243018821763 Content-Disposition: form-data; name="MAX_FILE_SIZE" 100000 -----------------------------149243018821763 Content-Disposition: form-data; name="u" username -----------------------------149243018821763 Content-Disposition: form-data; name="p" password -----------------------------149243018821763-- 

2 Answers 2

4

Try...

Request.Files["file"] 

Reflector shows that files are excluded from the Request.Form collection.

Sign up to request clarification or add additional context in comments.

Comments

1

I'm assuming you're using a FileUpload control.... You need to put something like this in your Page_Load.

if (FileUpload1.HasFile) { if (System.IO.Path.GetExtension(FileUpload1.FileName).ToLower() == ".jpg") { fileOK = true; } if (fileOK) { try { FileUpload1.PostedFile.SaveAs(System.IO.Path.Combine(path, newFileName + ".jpg")); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.