《PHP編程:php隱藏實際地址的文件下載方法》要點:
本文介紹了PHP編程:php隱藏實際地址的文件下載方法,希望對您有用。如果有疑問,可以聯(lián)系我們。
PHP教程本文實例講述了php暗藏實際地址的文件下載方法.分享給大家供大家參考.具體如下:
PHP教程下面這段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教程實現(xiàn)辦法二:
PHP教程
<?php
$file = "1.txt";// 文件的真實地址(支持url,不過不建議用url)
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>
PHP教程希望本文所述對大家的php程序設計有所贊助.
《PHP編程:php隱藏實際地址的文件下載方法》是否對您有啟發(fā),歡迎查看更多與《PHP編程:php隱藏實際地址的文件下載方法》相關教程,學精學透。維易PHP學院為您提供精彩教程。