您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php隐藏实际文件地址

2024/4/13 20:10:33发布20次查看
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'); 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隐藏实际文件地址的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product