You are here

function file_aliases_load_fid in File Aliases 6

Same name and namespace in other branches
  1. 5 file_aliases.module \file_aliases_load_fid()
  2. 7 file_aliases.module \file_aliases_load_fid()
1 string reference to 'file_aliases_load_fid'
file_aliases_menu in ./file_aliases.module
Implements hook_menu().

File

./file_aliases.module, line 147
Contains core functions for the File Aliases module.

Code

function file_aliases_load_fid($fid) {
  if (request_uri() == base_path() . 'filefield_paths/alias/' . $fid) {
    drupal_not_found();
    exit;
  }
  $result = db_fetch_object(db_query("SELECT filemime, filepath FROM {files} WHERE fid = %d", $fid));
  if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
    file_download($result->filepath);
  }
  else {
    header('Content-Type: ' . $result->filemime);

    // Fix for IE/PDF download issue
    // @see http://drupal.org/node/411910
    header('Cache-Control: public');
    readfile($result->filepath);
  }
}