我在下面写了代码,用于在我的app中上传图片。我设置了上传图片的路径。以下代码在我的系统和公司的服务器中正确填写。但是当我发布客户网站时。在主机中找不到此路径并产生HTTP ERROR 404.0 -NOT Found。
`string pic = System.IO.Path.GetFileNameWithoutExtension(model.ImageUpload.FileName) + Guid.NewGuid() + System.IO.Path.GetExtension(model.ImageUpload.FileName);
string path = System.IO.Path.Combine(
Server.MapPath("~"), "Areas/Administrator/uploads/", pic);
string PicPath = System.IO.Path.Combine("/Areas/Administrator/uploads", pic);
PicPath = PicPath.Replace("\\", "/");
model.ImageUpload.SaveAs(path);
bImageUpload.Inser(new Shared.Entities.SMP.ImageUpload
{
Title = model.Titel,
Lang = CultureHelper.GetLangFromCulture(),
ImageUrl = PicPath
});`
答案 0 :(得分:0)
模拟错误:
将图像从文件夹中导出到这样的项目文件中:
Server.MapPath("~/image.jpg"))
然后将您的项目作为测试运行。