function file_download_access

7.x file.inc file_download_access($uri)
6.x file.inc file_download_access($filepath)

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

$uri: The URI for the file whose access should be retrieved.

Return value

Boolean TRUE if access is allowed. FALSE if access is not allowed.

See also

file_download_headers()

hook_file_download()

Related topics

1 call to file_download_access()
file_managed_file_value in drupal/modules/file/file.module
The #value_callback for a managed_file type element.
1 string reference to 'file_download_access'
file_file_download in drupal/modules/file/file.module
Implements hook_file_download().

File

drupal/includes/file.inc, line 2069
API for handling file uploads and server file management.

Code

function file_download_access($uri) {
  return count(file_download_headers($uri)) > 0;
}