function file_create_url
7.x file.inc | file_create_url( |
6.x file.inc | 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
5 calls to file_create_url()
- blogapi_metaweblog_new_media_object in drupal-6.x/
modules/ blogapi/ blogapi.module - Blogging API callback. Inserts a file into Drupal.
- template_preprocess_user_picture in drupal-6.x/
modules/ user/ user.module - Process variables for user-picture.tpl.php.
- theme_upload_attachments in drupal-6.x/
modules/ upload/ upload.module - Displays file attachments in table
- upload_nodeapi in drupal-6.x/
modules/ upload/ upload.module - Implementation of hook_nodeapi().
- _upload_form in drupal-6.x/
modules/ upload/ upload.module
File
- drupal-6.x/
includes/ file.inc, line 40 - API for handling file uploads and server file management.
Code
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));
}
}