+
80
-

php如何让浏览器下载一个文本文件?

php

请问php如何让浏览器下载一个文本文件?

网友回复

+
0
-
<?php
$content = "文本内容";//文件内容
header("Content-type: application/octet-stream"); 
header("Accept-Ranges: bytes"); 
header("Content-Disposition: attachment; filename = filename.txt"); //文件命名
header("Expires: 0"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
header("Pragma: public"); 
echo $content;

我知道答案,我要回答