使用提示从SQL blob保存到客户端计算机 [英] Save from SQL blob to client machine with prompt

查看:70
本文介绍了使用提示从SQL blob保存到客户端计算机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个ASP.NET网络应用程序和一个从SQL BLOB检索到一个字节[]的文件。



假设我有一个名为myData的byte []中的数据。

byte [] myData = MyDataToBeSaved;



我需要将此文件保存到客户端计算机。保存浏览器时应提示保存文件的位置。

Hi,

I have a ASP.NET web-application and a file retrieved from SQL BLOB into a byte[].

Suppose I have the data in a byte[] called myData.
byte[] myData= MyDataToBeSaved;

I need to save this file to the client machine. While saving the browser should prompt the location where to save the file.

推荐答案

您无法通过浏览器提示任何内容 - 由用户自行决定。

您甚至无法让浏览器保存它而不是打开它!

要传输文件很简单:

You cannot make the browser prompt for anything - that is at the user discretion.
You can't even make the browser save it instead of opening it!
To transfer the file is simple:
Response.Clear();
Response.AddHeader("Cache-Control", "no-cache, must-revalidate, post-check=0, pre-check=0");
Response.AddHeader("Pragma", "no-cache");
Response.AddHeader("Content-Description", "File Download");
Response.AddHeader("Content-Type", "application/force-download");
Response.AddHeader("Content-Transfer-Encoding", "binary\n");
Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
Response.BinaryWrite(data);
Response.End();


这篇关于使用提示从SQL blob保存到客户端计算机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆