You are here

function imce_file_download in IMCE 6

Same name and namespace in other branches
  1. 8.2 imce.module \imce_file_download()
  2. 8 imce.module \imce_file_download()
  3. 5 imce.module \imce_file_download()
  4. 6.2 imce.module \imce_file_download()
  5. 7 imce.module \imce_file_download()

Implementation of hook_file_download().

File

./imce.module, line 92

Code

function imce_file_download($file) {
  $serve = variable_get('file_downloads', '') == FILE_DOWNLOADS_PRIVATE && !variable_get('imce_settings_disable_private', 0) && ($path = file_create_path($file)) && file_exists($path);
  if ($serve) {
    if ($result = db_result(db_query("SELECT filemime FROM {files} WHERE filepath = '%s'", $path))) {
      $type = $result;
    }
    elseif (function_exists('file_get_mimetype')) {
      $type = file_get_mimetype($path);
    }
    else {
      $type = 'application/x-download';
    }
    return array(
      'Content-type: ' . $type,
      'Content-Length: ' . filesize($path),
    );
  }
}