| Versionen | |
|---|---|
| drupal6 – drupal7 | file_create_url($path) |
Create the download path to a file.
$path A string containing the path of the file to generate URL for.
A string containing a URL that can be used to download the file.
includes/
<?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));
}
}
?>
Kommentare
Kommentar hinzufügen