[英]Saving images relative to content directory where my site is running in IIS
我想將從ASP MVC頁面上傳的圖像保存到content / img /文件夾,該文件夾相對於我的網站在IIS中運行的位置。 但是我不想將文件系統上的位置硬編碼為絕對路徑,因為這很容易更改。 這是我用來保存它們的代碼。
public static string SaveCompanyLogoImage(HttpPostedFileBase file)
{
var newFileName = GetNewCompanyLogoFileName(file.FileName);
file.FileName = newFileName;
file.SaveAs(//relative-location-here);
return Path.GetFileNameWithoutExtension(last);
}
希望這能解釋我的問題!
感謝您的協助
使用Server.MapPath(“〜/ MyImagesFolder”)
http://msdn.microsoft.com/es-es/library/system.web.httpserverutility.mappath.aspx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.