Answered by:
File Upload

Question
-
Answers
-
Hi
This article might shed some light
Best regards Karl-Henrik "KH" Nilsson - You can find me at my blog or Follow @KHNilsson on Twitter
- Proposed as answer by Jason Dot Wang Tuesday, May 21, 2013 5:48 AM
- Marked as answer by Jason Dot Wang Monday, May 27, 2013 8:52 AM
-
You can use the following code:
protected void btnUpload_Click(object sender, EventArgs e) { try { // Get the HttpFileCollection HttpFileCollection hfc = Request.Files; for (int i = 0; i < hfc.Count; i++) { HttpPostedFile hpf = hfc[i]; if (hpf.ContentLength > 0) { hpf.SaveAs(Server.MapPath("MyFiles") + "\\" + System.IO.Path.GetFileName(hpf.FileName)); Response.Write("File: " + hpf.FileName + " Size: " + hpf.ContentLength + " Type: " + hpf.ContentType + " Uploaded Successfully "); } } } catch (Exception ex) { } }
Mark as answer if this solves your problem. ... Best Regards D. Chatterjee MCA, RERF
- Marked as answer by Jason Dot Wang Monday, May 27, 2013 8:52 AM
All replies
-
Hi
This article might shed some light
Best regards Karl-Henrik "KH" Nilsson - You can find me at my blog or Follow @KHNilsson on Twitter
- Proposed as answer by Jason Dot Wang Tuesday, May 21, 2013 5:48 AM
- Marked as answer by Jason Dot Wang Monday, May 27, 2013 8:52 AM
-
-
You can use the following code:
protected void btnUpload_Click(object sender, EventArgs e) { try { // Get the HttpFileCollection HttpFileCollection hfc = Request.Files; for (int i = 0; i < hfc.Count; i++) { HttpPostedFile hpf = hfc[i]; if (hpf.ContentLength > 0) { hpf.SaveAs(Server.MapPath("MyFiles") + "\\" + System.IO.Path.GetFileName(hpf.FileName)); Response.Write("File: " + hpf.FileName + " Size: " + hpf.ContentLength + " Type: " + hpf.ContentType + " Uploaded Successfully "); } } } catch (Exception ex) { } }
Mark as answer if this solves your problem. ... Best Regards D. Chatterjee MCA, RERF
- Marked as answer by Jason Dot Wang Monday, May 27, 2013 8:52 AM