大家都知道文件下载的方法。我想再服务器端把文件以stream的方式推出来,到客户端后类似于文件下载的方法让用户保存。包括(txt.doc文件 就是下载doc.txt等文件也要象下载zip文件一样ie摊弹出另存为对话框.我在服务器端必须要用Stream的方式. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Response.AppendHeader("Content-Disposition", "attachment;filename=" + strDisplayname);请用attachment(用附件方式),如果用inline的话,就会直接在IE里打开了.看看是不是这个问题.如果还不行,给我发消息! down.aspx?path=d:\aa.docstring path = Request.QueryString["path"]; string fileName = Path.GetFileName(path); Response.Clear(); Response.ContentType = "application/octet-stream"; //Response.AddHeader("Content","charset=utf-8"); Response.AddHeader("Content-Disposition", "attachment; filename=" +HttpUtility.UrlEncode(fileName)); Response.WriteFile(path); 我还是有一个疑问。(atlove(星) 请你回答我在服务器端把文件以stream的形式读取出来.能直接的用Response推出来马? 只要通过脚本更改IE的HEADER,然后用标准输出方式就可以了。主要的是对HEADER的更改,决定了输出时的行为。下面的脚本是基于PHP的,FYI:-------------------------------------------------header("Content-type: application/download");header("Content-Disposition: filename=$name");$fp=fopen($strFullPath,"rb");fpassthru($fp);flush();------------------------------------------------- 随机读取Access数据记录的奇怪问题 GridView 中 checkBox 触发事件 参数 问题(等等等) 怎么远程导出SQL数据库以及数据 如何让listview显示磁盘某个路径下的文件夹或者文件(含图标和名称),就像资源管理器一样。 wpf发布网站问题 一个关于反射的简单问题 求C#字符串还原代码 listBox取值问题! 请问一下,原来有一编写关于公司为什么要用.net的文章在哪个地方 如何设置动态加载的路径? 兄弟一不小心现装了.Net,新在要装Vs6.0,怎么装? 关于操作回滚的技术讨论!
string fileName = Path.GetFileName(path);
Response.Clear();
Response.ContentType = "application/octet-stream";
//Response.AddHeader("Content","charset=utf-8");
Response.AddHeader("Content-Disposition", "attachment; filename=" +HttpUtility.UrlEncode(fileName));
Response.WriteFile(path);
我在服务器端把文件以stream的形式读取出来.能直接的用Response推出来马?
-------------------------------------------------
header("Content-type: application/download");
header("Content-Disposition: filename=$name");$fp=fopen($strFullPath,"rb");
fpassthru($fp);
flush();
-------------------------------------------------