文件我用這個代碼下載文件無法瀏覽網站,同時下載使用PHP
$file='test.mp3'; $download_rate = 50; //50 kb/s if(file_exists($file) && is_file($file)) { header('Cache-control: private'); header('Content-Type: application/octet-stream'); header('Content-Length: '.filesize($file)); header('Content-Disposition: filename='.$file); flush(); $file = fopen($file, "r"); while(!feof($file)) { // send the current file part to the browser print fread($file, round($download_rate * 1024)); // flush the content to the browser flush(); // sleep one second sleep(1); } fclose($file); } else { echo 'File Not Found'; }
但同時下載文件不能瀏覽該網站,直到下載完成。這發生在IE和火狐
任何答案?
不確定但不要調用flush();定義標題後,只需在輸出文件數據時調用該標題。 – 2011-03-31 15:09:12
這是什麼答案? – emaillenin 2011-08-21 10:14:52