PHP的header警告
来源:互联网 发布:把淘宝链接转换成文字 编辑:程序博客网 时间:2024/05/16 18:22
今天在学习PHP视频时,写的下载文件的程序总是报警告,且功能没有出来。
代码如下
<?php$file_name = "file.jpg";if ( !file_exists($file_name)) {echo "file not exist !";return ;}$fp = fopen($file_name, "rb");$file_size = filesize($file_name);header("Content-type: application/octet-stream");header("Accept-Ranges: bytes");header("Accept-Length: $file_size");header("Content-Disposition: attachment ; filename=".$file_name);$buffer = 1024;$read_data = "";while (!feof($fp)) {$read_data .= fread($fp, $buffer);}echo $read_data;fclose($fp);?>
警告如下
Warning: Cannot modify header information - headers already sent by (output started at D:\Web\AppServ\www\exe\downfile\down.php:1) inD:\Web\AppServ\www\exe\downfile\down.php on line 11
Warning
Warning: Cannot modify header information - headers already sent by (output started at D:\Web\AppServ\www\exe\downfile\down.php:1) inD:\Web\AppServ\www\exe\downfile\down.php on line 12
Warning: Cannot modify header information - headers already sent by (output started at D:\Web\AppServ\www\exe\downfile\down.php:1) inD:\Web\AppServ\www\exe\downfile\down.php on line 13
Warning: Cannot modify header information - headers already sent by (output started at D:\Web\AppServ\www\exe\downfile\down.php:1) inD:\Web\AppServ\www\exe\downfile\down.php on line 14
经过网上查找资料,并试过几种方法,最后用http://www.zreading.cn/ican/2012/01/wordpress-warning-cannot-modify-header-information-headers-already-sent-by/的方法得以解决,其实就是编码的问题,用“格式”->“以ANSI格式编码"即可,在此,谢谢这位朋友。
0 0
- PHP的header警告
- php下遇到 Cannot modify header information 的警告
- PHP出现"Cannot modify header information"警告的解决方法
- HttpClient4 警告: Invalid cookie header 的问题解决
- HttpClient4 警告: Invalid cookie header 的问题解决
- HttpClient4 警告: Invalid cookie header 的问题解决
- HttpClient4 警告: Invalid cookie header 的问题解决
- header的用法(PHP)
- PHP的HEADER
- header的用法(PHP)
- 解析PHP的header()
- header的用法(PHP)
- php header的用法
- php header的用法
- PHP中header的作用
- php header的用法小结
- php中header的用法
- php header的用法小结
- Linux学习(2014/3/13 )
- PAT系列索引
- mismatch,equal比较两序列
- FusionCharts多数据验证饼图label是否重叠
- oc门的设计思路
- PHP的header警告
- CareerCup An in-place algorithm for String Transformation
- string stringBuffer stringBuilder
- struts2的最少的5个核心jar包
- NOIP2002提高组 均分纸牌
- Android本地视频播放器开发--ffmpeg解码视频文件中的音频(1)
- WPF的Binding学习笔记(一)
- 图像显示和流媒体播放点解
- linux下常用FTP命令 1. 连接ftp服务器