Php hidden file download path instance

Source: Internet
Author: User
If we need to hide the download file path, we only need to enter it directly, without the need to jump to the path. let's look at an instance and hope it will help you. the code is as follows: & lt ;? Php

If we need to hide the download file path, we only need to enter it directly, without the need to jump to the path. let's look at an instance and hope it will help you. the code is as follows:

  1. // Set the header information and forcibly download the object
  2. Function download_send_headers ($ filename ){
  3. // Disable caching
  4. $ Now = gmdate ("D, d m y h: I: s ");
  5. Header ("Expires: Tue, 03 Jul 2001 06:00:00 GMT ");
  6. Header ("Cache-Control: max-age = 0, no-cache, must-revalidate, proxy-revalidate ");
  7. Header ("Last-Modified: {$ now} GMT ");
  8. // Force download
  9. Header ("Content-Type: application/force-download ");
  10. Header ("Content-Type: application/octet-stream ");
  11. Header ("Content-Type: application/download ");
  12. // Disposition/encoding on response body
  13. Header ("Content-Disposition: attachment; filename = {$ filename }");
  14. Header ("Content-Transfer-Encoding: binary ");
  15. }
  16. Using file_name+'download.csv ';
  17. $ File_path = dirname (_ FILE _). '/file/'. $ file_name;
  18. Download_send_headers ($ file_name );
  19. Readfile ($ file_path );
  20. Exit;
  21. ?>

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.