PHP编程:php隐藏实际地址的文件下载方法
发布时间:2020-12-13 02:34:47 所属栏目:PHP教程 来源:网络整理
导读:《php隐藏实际地址的文件下载方法》要点: 本文介绍了php隐藏实际地址的文件下载方法,希望对您有用。如果有疑问,可以联系我们。 PHP教程 本篇章节讲解php暗藏实际地址的文件下载方法.供大家参考研究.具体如下: PHP教程 下面这段php代码可不透露实
《php隐藏实际地址的文件下载方法》要点: 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教程实现办法二: 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,pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>
PHP教程希望本文所述对大家的php程序设计有所赞助. 《php隐藏实际地址的文件下载方法》是否对您有启发,欢迎查看更多与《php隐藏实际地址的文件下载方法》相关教程,学精学透。编程之家 52php.cn为您提供精彩教程。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |