I'm trying to save a file in my server. When I was running my code locally it was saving just fine but now on the server isn't working and I'm getting this message.
Could not find a part of the path 'C:\inetpub\folderPath\fileName.jpg'
My code is:
[HttpPost]
public string UploadFile() {
var file = HttpContext.Current.Request.Files.Count > 0 ?
HttpContext.Current.Request.Files[0] : null;
var pathFOLDER = @"C:\inetpub\folderPath\"
if (file != null && file.ContentLength > 0) {
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(
pathFOLDER,
fileName
);
file.SaveAs(path);
}
}
The problem is that the folder does exist. Some people said about permissions to save to the folder but i followed their steps and my problem wasn't solved. Is there an error in my code? Or how can I check if I have permission to save it or not?