| Versions | |
|---|---|
| 4.7 – 5 | hook_file_download( |
| 6 | hook_file_download( |
| 7 | hook_file_download($uri) |
Allow file downloads.
$file String of the file's path.
If the user does not have permission to access the file, return -1. If the user has permission, return an array with the appropriate headers.
developer/
<?php
function hook_file_download($file) {
if (user_access('access content')) {
if ($filemime = db_result(db_query("SELECT filemime FROM {fileupload} WHERE filepath = '%s'", file_create_path($file)))) {
return array('Content-type:' . $filemime);
}
}
else {
return -1;
}
}
?>