我写的是一个文件下载的程序:
<?
$w=strtok($title,".");
$tit=$w;
echo $tit;
echo $title;
$file_name ="$title";
$file_dir = "d:\homework\\";
$file_dir=$file_dir.$tit."\\";echo $file_dir;
$file_dir=addslashes($file_dir);
if (!file_exists($file_dir . $file_name)) { //检查文件是否存在
echo "文件找不到";
exit;
} else {
$file = fopen($file_dir . $file_name,"r"); // 打开文件
// 输入文件标签
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Accept-Length: ".filesize($file_dir . $file_name));
Header("Content-Disposition: attachment; filename=" . $file_name);
// 输出文件内容
echo fread($file,filesize($file_dir . $file_name));
fclose($file);
exit;}
?>
错误信息如下:
Warning: Cannot add header information - headers already sent by (output started at c:\apache\htdocs\ide\data\download.php:4) in c:\apache\htdocs\ide\data\download.php on line 18Warning: Cannot add header information - headers already sent by (output started at c:\apache\htdocs\ide\data\download.php:4) in c:\apache\htdocs\ide\data\download.php on line 19Warning: Cannot add header information - headers already sent by (output started at c:\apache\htdocs\ide\data\download.php:4) in c:\apache\htdocs\ide\data\download.php on line 20Warning: Cannot add header information - headers already sent by (output started at c:\apache\htdocs\ide\data\download.php:4) in c:\apache\htdocs\ide\data\download.php on line 21
请问这是什么错误了?