php文件下载实现方法
第一行代码是强制下载;
第二行代码是给下载的内容指定一个名字;
第三行代码是把下载的内容读进文件中。
提示用户保存一个生成的 pdf 文件(content-disposition 报头用于提供一个推荐的文件名,并强制浏览器显示保存对话框):
<?php教程 2 header("content-type: application/force-download"); 3 header("content-disposition: attachment; filename=ins.jpg"); 4 readfile("imgs/test_zoom.jpg"); 5
header() 函数向客户端发送原始的 http 报头。
认识到一点很重要,即必须在任何实际的输出被发送之前调用 header() 函数(在 php 4 以及更高的版本中,您可以使用输出缓存来解决此问题):
header(string,replace,http_response_code)
其它用法
<?php // date in the past header("expires: mon, 26 jul 1997 05:00:00 gmt"); header("cache-control: no-cache"); header("pragma: no-cache");
本文地址:http://www.phprm.com/code/37433.html
转载随意,但请附上文章地址:-)