输出text文件给用户

来源:互联网 发布:windows temp环境变量 编辑:程序博客网 时间:2024/05/17 08:46
$date=date("Ymd");$filename = $date."-".$this->user_id.".txt";$fp = fopen('./plugins/bijidown/'.$filename, 'w') or die("Unable to open file!");fwrite($fp, $str);$fp = fopen('./plugins/bijidown/'.$filename, 'r') or die("Unable to open file!");Header ( "Content-type: application/octet-stream" );Header ( "Accept-Ranges: bytes" );Header ( "Accept-Length: " . filesize ( './plugins/bijidown/' . $filename ) );Header ( "Content-Disposition: attachment; filename=" . $filename );//输出文件内容//读取文件内容并直接输出到浏览器echo fread ( $fp, filesize ( './plugins/bijidown/' . $filename ) );fclose ( $fp );exit ();
阅读全文
0 0
原创粉丝点击