upload_file_download

Versions
4.6 – 5
upload_file_download($file)
6
upload_file_download($filepath)
7
upload_file_download($uri)

Implement hook_file_download().

Code

modules/upload/upload.module, line 152

<?php
function upload_file_download($uri) {
  $file = db_query("SELECT f.*, u.nid FROM {file} f INNER JOIN {upload} u ON f.fid = u.fid WHERE uri = :uri", array(':uri' => $uri))->fetchObject();

  if ($file && user_access('view uploaded files') && ($node = node_load($file->nid)) && node_access('view', $node)) {
    return array(
      'Content-Type' => $file->filemime,
      'Content-Length' => $file->filesize,
    );
  }
  else {
    return -1;
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.