本文實例講述了php簡單實現文件或圖片強制下載的方法。分享給大家供大家參考,具體如下:
//下載function downregcaseAction() { $file="upload/regcase.jpg"; if(isfile($file)) { header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=".basename(file)); readfile(file); exit; } else { echo "文件不存在!"; exit; }}希望本文所述對大家PHP程序設計有所幫助。
新聞熱點
疑難解答
圖片精選