I want download window appear instead of showing my mp4 file I upload some mp4 files to my private folder and some users can access those files. this is my code for letting them download my mp4 files:

function my_module_file_download($uri) {

  // Get the file record based on the URI. If not in the database just return.
  $files = file_load_multiple(array(), array('uri' =&gt; $uri));
  if (count($files)) {
    foreach ($files as $item) {
      // Since some database servers sometimes use a case-insensitive comparison
      // by default, double check that the filename is an exact match.
      if ($item-&gt;uri === $uri) {
        $file = $item;
        break;
      }
    }
  }

  if (!isset($file)) {
    return;
  }

  // Put your permission check code here.

  // When done perform the following code    
  if ($can_access_file) {
    $headers = file_get_content_headers($file);
    return $headers;
  }  
  return -1; 
}


my problem: once my user clicks on the link of the file google chrome starts showing the file! although they can right click on the link of the file and download that, but i want the download window appear from beginning! maybe one solution is to zip the file but what about mp4 without zipping?
You can do this using htaccess, Open your .htaccess file and add the following...

&lt;FilesMatch "\.(mp4)$"&gt;
  ForceType application/octet-stream
  Header set Content-Disposition attachment
&lt;/FilesMatch&gt;


This should force the browser to do a left click download, rather than play the content. You can do it for multiple files types as well. After the mp4 just add |mp3, so it would look like &lt;FilesMatch “.(?i:(mp4|mp3|pdf))$”&gt;