SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist NokX's Avatar
    Join Date
    Feb 2003
    Location
    Knoxville, TN
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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
    Code:
    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?

    Code:
    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!

  2. #2
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,878
    Mentioned
    46 Post(s)
    Tagged
    0 Thread(s)
    Hi

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

  3. #3
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    660
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I'm guessing he is using WebForms. Here is an example of working with FileUpload class:

    http://www.chilkatsoft.com/p/p_534.asp
    Chuck Norris is so tough,
    mosquitos ask for permission before they bite him


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •