protected void Button1_Click(object sender, EventArgs e) { string filepath = "www.tnp.somee.com/Uploads"; HttpFileCollection uploadedFiles = Request.Files; for (int i = 0; i < uploadedFiles.Count; i++) { HttpPostedFile userPostedFile = uploadedFiles[i]; try { if (userPostedFile.ContentLength > 0) { Label1.Text += "<u>File #" + (i + 1) + "</u><br>"; Label1.Text += "File Content Type: " + userPostedFile.ContentType + "<br>"; Label1.Text += "File Size: " + userPostedFile.ContentLength + "kb<br>"; Label1.Text += "File Name: " + userPostedFile.FileName + "<br>"; userPostedFile.SaveAs(filepath + "\\" + System.IO.Path.GetFileName(userPostedFile.FileName)); Label1.Text += "Location where saved: " + filepath + "\\" + System.IO.Path.GetFileName(userPostedFile.FileName) + "<p>"; } } catch (Exception Ex) { Label1.Text += "Error: <br>" + Ex.Message; } } }
The SaveAs method is configured to require a rooted path, and the path 'www.tnp.somee.com/Uploads\Document.docx' is not rooted.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)