Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将应用程序/八位字节流从IE9中的javascript保存到磁盘_Javascript_File_Stream_Internet Explorer 9_Savefiledialog - Fatal编程技术网

将应用程序/八位字节流从IE9中的javascript保存到磁盘

将应用程序/八位字节流从IE9中的javascript保存到磁盘,javascript,file,stream,internet-explorer-9,savefiledialog,Javascript,File,Stream,Internet Explorer 9,Savefiledialog,我在WebApi上提供了下载文件的方法: public HttpResponseMessage Get(int id) { MemoryStream file = RetrieveFile(id); if (file != null) { var response = new HttpResponseMessage(HttpStatusCode.OK);

我在WebApi上提供了下载文件的方法:

public HttpResponseMessage Get(int id)
    {
            MemoryStream file = RetrieveFile(id);
            if (file != null)
            {
                var response = new HttpResponseMessage(HttpStatusCode.OK);
                response.Content = new StreamContent(file);
                response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
                response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = "dummy.txt"
                };

                return response;
            }


        return new HttpResponseMessage(HttpStatusCode.NotFound);
    }
这工作正常,我可以使用WebClient使用它

我还使用FileSaver.js实现了javascript前端:

$http({
            url: myUrl,
            method: 'GET',
            params: {
                id: 1
            },
            headers: {
                'Content-type': 'application/json'
            }
        }).success(function (data, status, headers, config) {
            var file = new Blob([data], {
                type: 'application/octet-stream'
            });
            saveAs(file, "test.txt");

        }).error(function (data, status, headers, config) {

        });
这非常有效,但在IE9上失败,因为不支持FileSaver和Blop。
我尝试在一个新窗口中打开url,但找不到一个合适的IE9解决方案

你有什么收获吗?@RichardMc没有,不可能