I have a program in asp.Net MVC. My server is plesk.
I save my files using this method:
public string SaveFile(HttpPostedFileBase file, string path)
{
string fileName = Guid.NewGuid() + file.FileName;
var filePath = Path.Combine(Server.MapPath("~/Images/"), fileName);
file.SaveAs(filePath);
return fileName;
}
and file saving is OK in test computer. But after uploading on server I get this error:
Could not find a part of the path 'C:\\Inetpub\\vhosts\\hostname.com\\mysitename.com\\Images\\myFile.jpg'
What is wrong with my code? Should I use something different when using plesk?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.