file_valid_uri

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 file_valid_uri($uri)

Determine 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

▾ 5 functions call file_valid_uri()

file_copy in includes/file.inc
Copies a file to a new location and adds a file record to the database.
file_delete in includes/file.inc
Delete a file and its database record.
file_move in includes/file.inc
Move a file to a new location and update the file's database entry.
file_save_data in includes/file.inc
Save a string to the specified destination and create a database file entry.
template_preprocess_user_picture in modules/user/user.module
Process variables for user-picture.tpl.php.

Code

includes/file.inc, line 812

<?php
function file_valid_uri($uri) {
  // Assert that the URI has an allowed scheme. Barepaths are not allowed.
  $uri_scheme = file_uri_scheme($uri);
  if (empty($uri_scheme) || !file_stream_wrapper_valid_scheme($uri_scheme)) {
    return FALSE;
  }
  return TRUE;
}
?>