這篇文章主要介紹了php隱藏實際地址的文件下載方法,涉及php中header與file_get_contents方法的相關使用技巧,非常具有實用價值,需要的朋友可以參考下
本文實例講述了php隱藏實際地址的文件下載方法。分享給大家供大家參考。具體如下:
下面這段php代碼可不透露實際的文件下載地址。
- function download_document($filename,$path="",$mimetype="application/octet-stream")
- {
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
- header("Content-Disposition: attachment; filename = $filename");
- header("Content-Length: " . filesize($pathto . $filename));
- header("Content-Type: $mimetype");
- echo file_get_contents($pathto . $filename);
- }
希望本文所述對大家的php程序設計有所幫助。
新聞熱點
疑難解答