Grabbing a file from an HTTPRequest post

According to Chrome’s built-in developer tool the file I’m sending is being passed to the server but I’m not able to find the file with ASP.

Here’s the info from the developer tool:

Request Paylod

Content-Disposition: form-data; name="certificate"; filename="Test Certificate.txt"

And I have this on my ASP page but they come up empty. What’s the preferred method for grabbing a posted file?

HttpFileCollection httpfile = Request.Files;
string httpfilename = "[File name here] (Count: " + httpfile.Count + ", Certificate: " + Request.Form["certificate"] + ")";


if (httpfile.Count > 0) {
	httpfilename = Server.MapPath("certificates/" + httpfile[0].FileName);
	httpfile[0].SaveAs(httpfilename);
}

httpfile.Count returns 0 and Request.Form[“certificate”] returns empty. What could I be missing? Thanks!

Hi

In what technology is this? Are you trying to do it with WebForms or MVC?

I’m guessing he is using WebForms. Here is an example of working with FileUpload class:

http://www.chilkatsoft.com/p/p_534.asp