成熟丰满熟妇高潮XXXXX,人妻无码AV中文系列久久兔费 ,国产精品一国产精品,国精品午夜福利视频不卡麻豆

您好,歡迎來(lái)到九壹網(wǎng)。
搜索
您的當(dāng)前位置:首頁(yè)php如何隱藏實(shí)際文件下載地址

php如何隱藏實(shí)際文件下載地址

來(lái)源:九壹網(wǎng)

php隱藏實(shí)際文件下載地址的方法:使用header與【file_get_contents】方法,代碼為【header("Content-Type: $mimetype");echo file_get_contents($pathto)】。

php隱藏實(shí)際文件下載地址的方法:

涉及php中header與file_get_contents方法的相關(guān)使用技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下:

實(shí)現(xiàn)方法一:

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);
}

實(shí)現(xiàn)方法二:

<?php
$file = "1.txt";// 文件的真實(shí)地址(支持url,不過(guò)不建議用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;
}
?>

想了解更多編程學(xué)習(xí),敬請(qǐng)關(guān)注php培訓(xùn)欄目!

Copyright ? 2019- 91gzw.com 版權(quán)所有 湘ICP備2023023988號(hào)-2

違法及侵權(quán)請(qǐng)聯(lián)系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市萬(wàn)商天勤律師事務(wù)所王興未律師提供法律服務(wù)