1 file.module file_file_is_readable($file)

Check if a file entity is readable or not.

Parameters

object $file: A file entity object from file_load().

Return value

boolean: TRUE if the file is using a readable stream wrapper, or FALSE otherwise.

File

core/modules/file/file.module, line 789
Defines a "managed_file" Form API field and a "file" field for Field module.

Code

function file_file_is_readable($file) {
  $scheme = file_uri_scheme($file->uri);
  $wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_READ);
  return !empty($wrappers[$scheme]);
}