You are here

function file_uri_target in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/includes/file.inc \file_uri_target()

Returns the part of a URI after the schema.

Parameters

string $uri: A stream, referenced as "scheme://target" or "data:target".

Return value

string|bool A string containing the target (path), or FALSE if none. For example, the URI "public://sample/test.txt" would return "sample/test.txt".

See also

file_uri_scheme()

Related topics

15 calls to file_uri_target()
ConfigExportUITest::testExport in core/modules/config/src/Tests/ConfigExportUITest.php
Tests export of configuration.
config_file_download in core/modules/config/config.module
Implements hook_file_download().
FileItemTest::testFileItem in core/modules/file/src/Tests/FileItemTest.php
Tests using entity fields of the file field type.
file_stream_wrapper_uri_normalize in core/includes/file.inc
Normalizes a URI by making it syntactically correct.
file_test_file_url_alter in core/modules/file/tests/file_test/file_test.module
Implements hook_file_url_alter().

... See full list

File

core/includes/file.inc, line 124
API for handling file uploads and server file management.

Code

function file_uri_target($uri) {

  // Remove the scheme from the URI and remove erroneous leading or trailing,
  // forward-slashes and backslashes.
  $target = trim(preg_replace('/^[\\w\\-]+:\\/\\/|^data:/', '', $uri), '\\/');

  // If nothing was replaced, the URI doesn't have a valid scheme.
  return $target !== $uri ? $target : FALSE;
}