Last post Mar 02, 2017 07:06 AM by oned_gk
Mar 01, 2017 08:59 PM|RDowdall|LINK
Hello - I have a forms authenticated application that resides on a server behind a reverse proxy, One page on my application has a file upload that attempts to upload an Excel file to a folder in the application root path. When I try to upload a file I
get the following error:
Can anyone point me in the right direction? I have searched around but nothing has worked yet. Thanks,
string fileName = System.IO.Path.GetFileName(Upload1.PostedFile.FileName);
string ext = Path.GetExtension(Upload1.FileName).ToLower();
string path = Path.Combine(Server.MapPath("/Temp/"), fileName);
Mar 02, 2017 05:14 AM|Eric Du|LINK
According to your description, Please try the following code:
<form id="form1" runat="server">
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick="UploadFile" />
<asp:Label ID="lblMessage" ForeColor="Green" runat="server" />
protected void UploadFile(object sender, EventArgs e)
string folderPath = Server.MapPath("~/Files/");
//Check whether Directory (Folder) exists.
//If Directory (Folder) does not exists. Create it.
//Save the File to the Directory (Folder).
FileUpload1.SaveAs(folderPath + Path.GetFileName(FileUpload1.FileName));
//Display the success message.
lblMessage.Text = Path.GetFileName(FileUpload1.FileName) + " has been uploaded.";
Mar 02, 2017 07:06 AM|oned_gk|LINK
string fileName = Upload1.PostedFile.FileName; //filename
//or string fileName = Upload1.FileName;
string path = Path.Combine(Server.MapPath("~/Temp/"), fileName); //ensure temp folder already there
~/ = app root folder