public string uploadFile(string fileName, string folderName) { if (fileName == "") { return "Invalid filename supplied"; } if (fileUpload.PostedFile.ContentLength == 0) { return "Invalid file content"; } fileName = System.IO.Path.GetFileName(fileName); if (folderName == "") { return "Path not found"; } try { if (fileUpload.PostedFile.ContentLength <= 2048000) { fileUpload.PostedFile.SaveAs(Server.MapPath(folderName) + "\\" + fileName); return "File uploaded successfully"; } else { return "Unable to upload,file exceeds maximum limit"; } } catch (UnauthorizedAccessException ex) { return ex.Message + "Permission to upload file denied"; } }
protected void btnSave_Click(object sender, EventArgs e) { string strFilename, strMessage; strFilename = fileUpload.PostedFile.FileName.ToString(); strMessage = uploadFile(strFilename, ConfigurationSettings.AppSettings["folderPath"]); lblMessage.Text = strMessage; //lblMessage.ForeColor = Color.Red; }
fileUpload.PostedFile.SaveAs(Server.MapPath(folderName) + "\\" + fileName);
Could not find a part of the path 'C:\Users\admin\Documents\Visual Studio 2008\WebSites\pmsw(new)\Admin\10.3.2\Concrete_Basement_Wall.xls'.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)