16 May 2018

This snippet shows you how to load a file by uri. Basically this option is available with file_load_mulitple only.

Source code viewer
  1. $uri = 'public://directory/file.xyz';
  2.  
  3. // @see file.inc::file_load_multiple
  4. $files = file_load_multiple(array(), array('uri' => $uri));
  5. $file = reset($files); // If empty, $file will be false, otherwise will contain the required file
Programming Language: PHP