Home  >  Article  >  php教程  >  连接到txt文本的超链接,不直接打开而是点击后下载的处理方法

连接到txt文本的超链接,不直接打开而是点击后下载的处理方法

WBOY
WBOYOriginal
2016-06-13 12:22:471199browse

服务器端两种处理方法,一个是apache或者iis or tomcat等服务器中进行设置,或者在程序中指定发送类型。
该信息属于http头部信息,php有直接进行头部信息操作的函数。
php的实现方法:

复制代码 代码如下:


header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($_GET['url']));
readfile($filename);
?>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn