Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 12:22:47
Original
1248 people have browsed it

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

复制代码 代码如下:


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


source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template