【问题标题】:HttpContext.Current.Request.Files[0].FileName returning blob for image filesHttpContext.Current.Request.Files[0].FileName 返回图像文件的 blob
【发布时间】:2016-10-20 18:40:51
【问题描述】:

我将一个文件作为 FormData 的一部分从 AngularJs 发送到 .NET Web API,如下所示:

AngularJS:

var cabinetFormData = new FormData();
cabinetFormData.append('file', file);

将上述FormData 作为服务调用中的参数发送到.Net WebAPI

.NET:

var httpRequest = HttpContext.Current.Request;
var fileRequest = httpRequest.Files[0];

在服务器端接收请求时,fileRequest.FileName 对于任何图像文件始终显示为“blob”。其余内容显示正常。为 .pdf 和 .xml 等其他格式获取正确的文件名。我检查了输入,它正在发送所有的 formData。

我做错了什么?

【问题讨论】:

    标签: c# angularjs asp.net-web-api httpcontext ng-file-upload


    【解决方案1】:

    我会将此作为评论发布,但我还没有代表..

    如果您在看到此问题时使用的是 Firefox,这些链接可能会对您有所帮助:

    Uploaded file comes in as blob if not on localhost? asp.net mvc4 using IIS express

    https://groups.google.com/forum/#!topic/jquery-fileupload/RjfHLX2_EeM

    :)

    【讨论】:

      猜你喜欢
      • 2018-08-11
      • 2015-10-28
      • 2022-01-06
      • 1970-01-01
      • 2012-01-16
      • 2015-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多