• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php隐藏实际文件地址

php 搞代码 4年前 (2022-01-22) 14次浏览 已收录 0个评论

php如何隐藏实际文件地址?这篇文章主要介绍了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$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<i>本文@来#源gaodai$ma#com搞$$代**码网</i><strong>搞代gaodaima码</strong>');  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 下载 file_put_contents vs readfile

以上就是php隐藏实际文件地址的详细内容,更多请关注搞代码gaodaima其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php隐藏实际文件地址

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址