$filename = $file; //文件路径 $mime = 'application/force-download'; header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: private',false); header('Content-Type: '.$mime); header('Content-Disposition: attachment; filename="'.basename($filename).'"'); header('Content-Transfer-Encoding: binary'); header('Connection: close'); readfile($filename); exit();
以上就介紹了PHP 下載txt檔案 功能,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。