[英]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.