PHP uses the ReadFile function to add permissions to the hidden download file address

Source: Internet
Author: User
Tags header readfile
1 <?php 以上代码实现了真是URL路径的隐藏功能, 本页开头可以进行权限判断。 2 效果如图,我们看到下面文件下载的URL已经被test.php隐藏.
$file = get_file_address ()//The real address of the file (URL is supported, but URL is not recommended)
03
if (file_exists ($file)) {
Header (' Content-description:file Transfer ');
Header (' Content-type:application/octet-stream ');
Modified 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;
17}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.