PHP upload file hidden path, do file upload security come in and see.

Source: Internet
Author: User
Tags php download
PHP download file hidden path, do file download security come in and see Oh!
Recently in the file resource management, when downloading the hidden file path is the only way to store files in the directory with Apache configuration so that it cannot directly access the directory list, rewrite technology can hide the server directory!
For example, the download path would be: Http://miresearch.cn/uploadfile/resource/2012-05/8F4F5A42-1B4C-8B80-0EFC-9FF2346373BF.rar
If not done, direct access to http://miresearch.cn/uploadfile/resource/2012-05 This can view all files in this directory of the server, and then after the Apache configuration so that HTTP/ Miresearch.cn/2012-05/8f4f5a42-1b4c-8b80-0efc-9ff2346373bf.rar can be implemented to download files to hide the server directory, and http://miresearch.cn/ 2012-05 This directory cannot be accessed directly.

Beginners to the file download only do so little work, please master to see, what good advice plan, to the younger brother under the guidance ~ have done file download security please come and see, under the guidance Oh ~

------Solution--------------------
Direct output file After account password verification ...

For example

PHP code
header (' Content-type:application/octet-stream '); $ FileSize = filesize (' s.png '); Get the file size header (' last-modified: '. Gmdate (' d, D M Y h:i:s '). ' GMT '); header (' Cache-control:no-store, No-cache, Must-revalidate '); header (' Cache-control:pre-check=0, post-check= 0, max-age=0 '); header (' content-transfer-encoding:binary '); header (' Content-encoding:none '); header (' Content-type: Application/force-download '), header (' Content-length: '. $filesize); header (' Content-disposition:attachment; Filename= "S.png"); ReadFile (' s.png '); 
  • 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.