为什么我的路径在客户主机中不是真的?

时间:2016-10-02 13:42:09

标签: asp.net-mvc html5 web-services asp.net-mvc-3 iis

我在下面写了代码,用于在我的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
                    });`

1 个答案:

答案 0 :(得分:0)

  1. 您的文件夹是否存在?
  2. 模拟错误:

    将图像从文件夹中导出到这样的项目文件中:

    Server.MapPath("~/image.jpg"))
    

    然后将您的项目作为测试运行。