file_create_url
- Versions
- 4.6 – 6
file_create_url($path)- 7
file_create_url($uri)
Create the download path to a file.
Parameters
$path Path to the file to generate URL for
Return value
URL pointing to the file
Related topics
Code
includes/file.inc, line 30
<?php
function file_create_url($path) {
if (strpos($path, variable_get('file_directory_path', 'files')) !== false) {
$path = trim(substr($path, strlen(variable_get('file_directory_path', 'files'))), '\\/');
}
switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
case FILE_DOWNLOADS_PUBLIC:
return $GLOBALS['base_url'] .'/'. variable_get('file_directory_path', 'files') .'/'. str_replace('\\', '/', $path);
case FILE_DOWNLOADS_PRIVATE:
return url('system/files', 'file='. $path, NULL, TRUE);
}
}
?>Login or register to post comments 