file_uri_target($uri)
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
Related topics
- File interface
- Common file handling functions.
File
- core/includes/file.inc, line 109
- API for handling file uploads and server file management.
Code
1 2 3 4 5 6 7 8 | 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; } |
Please login to continue.