包括目前常用的web程序开发的代码,原理其实就是设置文件头(Header)信息而已| 代 码 : |
<!--- cf ---> <cfheader name="Content-Type" value="application/unknown"> <cfheader name="content-disposition" value="attachment; filename=aaa.xls"> |
|
| 代 码 : |
<% //jsp response.setContentType("application/unknown;charset=gbk"); response.addHeader("content-disposition","attachment;filename=aaa.xls"); %> |
|
| 代 码 : |
<% 'asp 或 asp.net response.ContentType = "application/msexcel" response.AddHeader "content-disposition","attachment; filename=aaa.xls" %> |
|
| 代 码 : |
<?php //php header("Content-type: application/msexcel"); header("Content-Disposition: attachment; filename=aaa.xls"); ?> |
|
说明一下:filename=aaa.xls这个是默认下载的文件名;
application/unknown这个是指定当前页面生成的文件类型,这可以对应着
windows里的MIME类型名称;
如是指定是word文档,你可以设置“application/msword”,指定是excel文档,你可设置“application/msexcel”。
查看更多与有关Web页面内容文件强制下载代码整理相关内容