1、php輸出文件時候,瀏覽器下載該文件
$file = "./a.png"; header('Content-Disposition:attachment; filename=1.png'); echo file_get_contents($file);
2、PHP輸出圖片,瀏覽器中直接打開圖片
$file = "./a.png"; header('Content-type:image/png'); echo file_get_contents($file);
3、PHP輸出pdf,瀏覽器直接打開pdf
$file = "wangshili.pdf"; header('Content-Type:application/pdf'); echo file_get_contents($file);