Function to force download of a file

  1.  
  2. <?php
  3. //———————————————– //  
  4. Function to force download of a file
  5. //———————————————–
  6. public function download($file_name, $file_path, $mime_type)
  7. {
  8.         header(‘Content-Description: File Transfer’);
  9.         header(‘Content-Type: ‘.$mime_type);
  10.         header(‘Content-Disposition: attachment; filename="’.$file_name.‘";’);
  11.         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  12.         header(‘Content-Length: ‘ .    filesize($file_path));
  13.         @readfile($file_path);
  14.         die();
  15. }
  16. ?>
  17.  




Sphere: Related Content

Related posts:

  1. Function to force download of a file   //———————————————– // Function to force download of a...
  2. The Oscillatory Phenomena Of Mass-Spring Systems 1. The System In Equilibrium: When the system is...

Related posts brought to you by Yet Another Related Posts Plugin.


0 Responses to “Function to force download of a file”

  1. No Comments

Leave a Reply

You must login to post a comment.



-->

Handy Tools

Search for a domain name

Search for a taken domain name