file_create_url

6/includes/file.inc, line 40

Versions
5 – 6
file_create_url($path)

Create the download path to a file.

Parameters

$path A string containing the path of the file to generate URL for.

Return value

A string containing a URL that can be used to download the file.

Related topics

▾ 34 functions call file_create_url()

apachesolr_attachments_add_documents in contributions/apachesolr/contrib/apachesolr_attachments/apachesolr_attachments.module
Callback for apachesolr_index_nodes().
asset_asset_formatter in contributions/asset/inc/asset.api.inc
Implementation of hook_asset_formatter().
asset_lightbox in contributions/asset/asset.module
Integrate asset with lightbox
asset_load in contributions/asset/inc/asset.node.inc
Load an asset object from db and set some default properties. Taken almost exactly from node_load to utilize caching and assetapi load hook
blogapi_metaweblog_new_media_object in 6/modules/blogapi/blogapi.module
Blogging API callback. Inserts a file into Drupal.
contemplate_nodeapi in contributions/contemplate/contemplate.module
Implementation of hook_nodeapi().
file_create_url in 6/includes/file.inc
Create the download path to a file.
imagecache_create_url in contributions/imagecache/imagecache.module
Return a URL that points to the location of a derivative of the original image at @p $path, transformed with the given @p $preset.
imagecache_field_formatter in contributions/imagecache/imagecache.module
Implementation of hook_field_formatter().
image_display in contributions/image/image.module
Create an <img> tag for an image.
img_assist_render_image in contributions/img_assist/img_assist.module
Return image HTML.
shadowbox_imagecache_create_url in contributions/shadowbox/shadowbox.module
Implementation of the imagecache_create_url() function for integration with imagecache module versions prior to imagecache 2.
swftools_generate_playlist in contributions/swftools/swftools.module
Saves a playlist/xml file to a directory ready for the browser callback. Data must be formatted correctly, see docs (link to come) Returns a fully qualified url to the playlist file
swftools_get_media_url in contributions/swftools/swftools.module
Resolved a path to a full url. The path must be relative to the webroot. We check for the existence if a file is the follow is true: swftools_media_url is empty, and hence the local server is assumed. $is_file is TRUE. (You can set this to FALSE if...
template_preprocess_user_picture in 6/modules/user/user.module
Process variables for user-picture.tpl.php.
theme_audio_image in contributions/audio/images/audio_images.module
Create an <img> element for an audio image.
theme_filefield_file in contributions/filefield/filefield_formatter.inc
Theme function for the 'generic' single file formatter.
theme_filefield_formatter_url_plain in contributions/filefield/filefield_formatter.inc
Theme function for the 'url_plain' formatter.
theme_imagefield_image in contributions/imagefield/imagefield.module
@defgroup "Theme Callbacks" See alsoimagefield_theme()
theme_imagefield_image_imagecache_shadowbox in contributions/shadowbox/shadowbox.module
Implementation of theme_imagefield_image_imagecache_shadowbox().
theme_imagefield_image_imagecache_thickbox in contributions/thickbox/thickbox.module
Implementation of theme_imagefield_image_imagecache_thickbox().
theme_inline_as_link in contributions/inline/inline.theme.inc
Return HTML for a link to a file.
theme_inline_upload_as_link in contributions/inline/inline_upload.module
Return HTML for a link to a file.
theme_lightbox2_file_formatter_lightbox2_iframe in contributions/lightbox2/lightbox2.formatter.inc
Theme function for the lightbox iframe filefield formatter.
theme_shadowbox_image in contributions/shadowbox/shadowbox.module
Theme function for displaying the shadowbox trigger image in an imagefield.
theme_upload_attachments in 6/modules/upload/upload.module
Displays file attachments in table
theme_webform_mail_file in contributions/webform/components/file.inc
Format the output of emailed data for this component
uc_catalog_get_page in contributions/ubercart/uc_catalog/uc_catalog.module
Load catalog information for display.
upload_nodeapi in 6/modules/upload/upload.module
Implementation of hook_nodeapi().
webform_file_url in contributions/webform/components/file.inc
Helper function to create proper URLs for uploaded file.
_avatar_selection_image_list in contributions/avatar_selection/avatar_selection.module
Get the list of avatars available to a certain user.
_private_upload_create_url in contributions/private_upload/private_upload.module
Create a URL for the file that changes if the file is public or private. TODO - Push to get a file_create_url hook into Drupal7.
_urlicon_format_favicon in contributions/urlicon/urlicon.module
Callback for filter
_webform_submission_display_file in contributions/webform/components/file.inc
Display the result of a file submission. The output of this function will be displayed under the "results" tab then "submissions".

Code

<?php
function file_create_url($path) {
  // Strip file_directory_path from $path. We only include relative paths in urls.
  if (strpos($path, file_directory_path() .'/') === 0) {
    $path = trim(substr($path, strlen(file_directory_path())), '\\/');
  }
  switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
    case FILE_DOWNLOADS_PUBLIC:
      return $GLOBALS['base_url'] .'/'. file_directory_path() .'/'. str_replace('\\', '/', $path);
    case FILE_DOWNLOADS_PRIVATE:
      return url('system/files/'. $path, array('absolute' => TRUE));
  }
}
?>