【问题标题】:why isn't my path true in Customer host?为什么我的路径在客户主机中不是真的?
【发布时间】:2023-03-19 22:19:01
【问题描述】:

我在我的应用程序中编写了以下用于上传图像的代码。我设置了上传图像的路径。下面的代码在我的系统和公司的服务器中是正确的。但是当我发布客户网站时。在主机中找不到此路径并产生 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
                    });`

【问题讨论】:

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


    【解决方案1】:
    1. 您的文件夹存在吗?
    2. 模拟错误:

      将图像从文件夹中取出到项目文件中,如下所示:

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

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

    【讨论】:

      猜你喜欢
      • 2019-11-19
      • 2010-09-24
      • 1970-01-01
      • 2011-03-14
      • 2016-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-31
      相关资源
      最近更新 更多