function file_download_access in Drupal 6
Same name and namespace in other branches
- 7 includes/file.inc \file_download_access()
Checks that the current user has access to a particular file.
The return value of this function hinges on the return value from file_download_headers(), which is the function responsible for collecting access information through hook_file_download().
If immediately transferring the file to the browser and the headers will need to be retrieved, the return value of file_download_headers() should be used to determine access directly, so that access checks will not be run twice.
Parameters
$filepath: The path for the file whose headers should be retrieved.
Return value
Boolean TRUE if access is allowed. FALSE if access is not allowed.
See also
hook_file_download()
Related topics
File
- includes/
file.inc, line 1036 - API for handling file uploads and server file management.
Code
function file_download_access($filepath) {
return count(file_download_headers($filepath)) > 0;
}