On this page
function file_valid_uri
file_valid_uri($uri)
Determines whether the URI has a valid scheme for file API operations.
There must be a scheme and it must be a Drupal-provided scheme like 'public', 'private', 'temporary', or an extension provided with hook_stream_wrappers().
Parameters
$uri: The URI to be tested.
Return value
TRUE if the URI is allowed.
Related topics
- File interface
- Common file handling functions.
File
- core/includes/file.inc, line 405
- API for handling file uploads and server file management.
Code
function file_valid_uri($uri) {
// Assert that the URI has an allowed scheme. Bare paths are not allowed.
$uri_scheme = \Drupal::service('file_system')->uriScheme($uri);
if (!file_stream_wrapper_valid_scheme($uri_scheme)) {
return FALSE;
}
return TRUE;
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!file.inc/function/file_valid_uri/8.1.x