怎样输出 图片 下载?

博客提出ASP.NET可直接输出doc、zip、rar等IIS不能解释格式文件下载,但对于Bmp、Gif、Jepg格式无法实现,询问怎样实现这类文件下载并出现保存对话框,还给出了转载来源。

ASP.NET可以直接输出文件下载,例如doc,zip,rar这类IIS不能解释的格式,如果是Bmp,Gif,Jepg就不行了,怎样实现其下载呢(出现保存那个对话框)?

None.gif      //  Identify the file to download including its path.
None.gif
     string  filepath  =  DownloadFileName;
None.gif
None.gif    
//  Identify the file name.
None.gif
     string  filename  =  System.IO.Path.GetFileName(filepath);
None.gif
None.gif    Response.Clear();
None.gif
None.gif    
//  Specify the Type of the downloadable file.
None.gif
    Response.ContentType  =   " application/octet-stream " ;
None.gif
None.gif    
//  Set the Default file name in the FileDownload dialog box.
None.gif
    Response.AddHeader( " Content-Disposition " " attachment; filename= "   +  filename);
None.gif
None.gif    Response.Flush();
None.gif
None.gif    
//  Download the file.
None.gif
    Response.WriteFile(filepath);

看了 http://www.cnblogs.com/koffer/archive/2004/10/14/52289.htmlt也没有发现答案! 

BTW:Response.WriteFile 无法下载大文件

转载于:https://www.cnblogs.com/caca/archive/2005/08/28/224565.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值