| 5 file.inc | file_create_url($path) |
| 6 file.inc | file_create_url( |
| 7 file.inc | file_create_url($uri) |
| 8 file.inc | file_create_url($uri) |
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
File
- includes/
file.inc, line 28 - API for handling file uploads and server file management.
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, NULL, NULL, TRUE);
}
}
?> Login or register to post comments
Comments
uploading logo file
Where does Drupal log the new logo I just updated? I mean I noticed that the new logo is no longer pointing to the same file directory as it used to and is now pointing the ~/files directory. Is this information stored in the database or registry? Thanks.