-4
Possible Duplicate:
Headers already sent by PHP警告:頭信息
我在PHP中的begginner,我想創建一個下載按鈕,但我收到了我不明白的錯誤。 這是我的錯誤:
"Warning: Cannot modify header information - headers already sent by (output started at D:\Program Files\xampp\htdocs\FormsGenerator\index.php:125) in D:\Program Files\xampp\htdocs\FormsGenerator\download.php on line 11"
在125行我有開放的PHP標籤調用創建功能。 這是我的按鈕功能的鱈魚:
<?php
class fileDownload{
function fileDownload(){
$core_path = dirname(__FILE__);
$file_path = "{$core_path}/file/form.html";
$file_info = array(
'name' => basename($file_path),
'size' => filesize($file_path)
);
header('Content-Type: application/html');
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="'.$file_info['name'].'"');
header('Content-Lenght: '.$file_info['size']);
$file = fopen($file_path, 'rb');
while(!feof($file)){
echo fread($file, 256);
}
fclose($file);
return;
}
}
?>
這裏是調用類所創建的對象:
if(isset($_GET['download'])){
include 'download.php';
$download = new fileDownload();
}
有人能幫助我嗎?
在'' –
之前或之後查找空行像空行一樣查找附件發送到瀏覽器之前發送的任何輸出。另外,看起來你在這裏犯了一個錯誤:'header('Content-Lenght:'。$ file_info ['size']);'(應該是內容長度) – user1909426