function file_create_url


Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/
cis7 file_create_url($uri)
cle7 file_create_url($uri)
elmsmedia7 file_create_url($uri)
icor7 file_create_url($uri)
meedjum_blog7 file_create_url($uri)
mooc7 file_create_url($uri)

Creates a web-accessible URL for a stream to an external or local file.

Compatibility: normal paths and stream wrappers.

There are two kinds of local files:

  • "managed files", i.e. those stored by a Drupal-compatible stream wrapper. These are files that have either been uploaded by users or were generated automatically (for example through CSS aggregation).
  • "shipped files", i.e. those outside of the files directory, which ship as part of Drupal core or contributed modules or themes.


$uri: The URI to a file for which we need an external URL, or the path to a shipped file.

Return value

A string containing a URL that may be used to access the file. If the provided string already contains a preceding 'http', 'https', or '/', nothing is done and the same string is returned. If a stream wrapper could not be found to generate an external URL, then FALSE is returned.

See also

Related topics

53 calls to file_create_url()
adaptivetheme_form_system_theme_settings_alter in sites/all/themes/ulmus/adaptivetheme/at_core/theme-settings.php
@file Implimentation of hook_form_system_theme_settings_alter()
adaptivetheme_html_head_alter in sites/all/themes/ulmus/adaptivetheme/at_core/inc/
advagg_get_root_files_dir in sites/all/modules/ulmus/advagg/advagg.module
Get the CSS & JS path for advagg.
advagg_install_check_via_http in sites/all/modules/ulmus/advagg/advagg.install
Make sure http requests to css/js files work correctly.
advagg_mod_advagg_get_root_files_dir_alter in sites/all/modules/ulmus/advagg/advagg_mod/advagg_mod.module
Implements hook_advagg_get_root_files_dir_alter().

... See full list


includes/, line 372
API for handling file uploads and server file management.


function file_create_url($uri) {
  // Allow the URI to be altered, e.g. to serve a file from a CDN or static
  // file server.
  drupal_alter('file_url', $uri);

  $scheme = file_uri_scheme($uri);

  if (!$scheme) {
    // Allow for:
    // - root-relative URIs (e.g. /foo.jpg in
    // - protocol-relative URIs (e.g. //bar.jpg, which is expanded to
    // by the browser when viewing a page over
    //   HTTP and to when viewing a HTTPS page)
    // Both types of relative URIs are characterized by a leading slash, hence
    // we can use a single check.
    if (drupal_substr($uri, 0, 1) == '/') {
      return $uri;
    else {
      // If this is not a properly formatted stream, then it is a shipped file.
      // Therefore, return the urlencoded URI with the base URL prepended.
      return $GLOBALS['base_url'] . '/' . drupal_encode_path($uri);
  elseif ($scheme == 'http' || $scheme == 'https') {
    // Check for HTTP so that we don't have to implement getExternalUrl() for
    // the HTTP wrapper.
    return $uri;
  else {
    // Attempt to return an external URL using the appropriate wrapper.
    if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
      return $wrapper->getExternalUrl();
    else {
      return FALSE;



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.