Asp.net mvc 4 将照片上载到服务器时出现运行时错误
为什么在尝试将照片上载到服务器时出现此错误: 我有以下代码: 在Web.config中:Asp.net mvc 4 将照片上载到服务器时出现运行时错误,asp.net-mvc-4,upload,runtime-error,Asp.net Mvc 4,Upload,Runtime Error,为什么在尝试将照片上载到服务器时出现此错误: 我有以下代码: 在Web.config中: <configuration> <system.web> <httpRuntime maxRequestLength="2097152" /> </system.web> </configuration> 错误是: 编辑: 我有一个名为taghbazar.ir的域名和一个主机。我买了另一个名为uask.i
<configuration>
<system.web>
<httpRuntime maxRequestLength="2097152" />
</system.web>
</configuration>
错误是:
编辑:
我有一个名为taghbazar.ir
的域名和一个主机。我买了另一个名为uask.ir
的域名,并将我的主机空间从taghbazar.ir
更改为uask.ir
。我想问题就在那里。如何解决?
错误显示:
正如错误页面所提到的,您是否尝试过将customErrors模式设置为OFF并查看详细错误?您可能应该向主机提供商查询允许保存文件的确切位置。非常感谢您的帮助,我的朋友。;)
public static void UploadImage(string folder, HttpPostedFileBase file)
{
string uploadFolderPath = HttpContext.Current.Server.MapPath("~/Images/" + folder);
string fileName = Path.GetFileName(file.FileName);
string filePath = Path.Combine(uploadFolderPath, fileName);
file.SaveAs(filePath);
}