我正在做一些内容为文本的文本文件,但是每当我下载文件时,我在文件中获得的内容都是<h
,并且没有内容。这是我的代码:生成可下载的文件时不下载内容使用php
$filename = 'download.txt';
$content = "Hi";
$f = fopen($filename, 'w');
fwrite($f, $content);
fclose($f);
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Length: ". filesize("$filename").";");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Type: application/octet-stream; ");
header("Content-Transfer-Encoding: binary");
readfile($filename);
,什么也不做:( –