【问题标题】:getting different paths using HttpPostedFileBase使用 HttpPostedFileBase 获取不同的路径
【发布时间】:2011-02-07 10:44:43
【问题描述】:

请参阅以下代码。我正在上传文件,但我从不同的浏览器得到不同的结果。

Firefox var path = "about.restaurant.jpg"

然而在 ie6 路径 = "D:\dev\xxxxx\xxxxx\xxxxx\Website\images\about.restaurant.jpg"

 foreach (string file in Request.Files)
 {
        var hpf = Request.Files[file] as HttpPostedFileBase;
        var path = hpf.FileName;
 }

我在 MVC2 中遇到了这个问题。刚刚升级到MVC3。存在同样的问题。

<form action="/Product/SaveUploadImage" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file" />
<input type="submit" value="Save" class="button" />
</form>

【问题讨论】:

    标签: asp.net asp.net-mvc-3


    【解决方案1】:

    啊,好吧,我明白了。所以有一种方法可以解决这一切

    Path.GetFileName(hpf.FileName)

    【讨论】:

      猜你喜欢
      • 2013-07-26
      • 2018-04-09
      • 1970-01-01
      • 2019-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-18
      相关资源
      最近更新 更多