file_download
includes/file.inc, строка 828
- Версии
- 5 – 6
file_download()
Call modules that implement hook_file_download()
to find out if a file is
accessible and what headers it should be transferred with. If a module
returns -1 drupal_access_denied()
will be returned. If one or more modules
returned headers the download will start with the returned headers. If no
modules respond drupal_not_found()
will be returned.
Связанные темы
Код
<?php
function file_download() {
// Merge remainder of arguments from GET['q'], into relative file path.
$args = func_get_args();
$filepath = implode('/', $args);
// Maintain compatibility with old ?file=paths saved in node bodies.
if (isset($_GET['file'])) {
$filepath = $_GET['file'];
}
if (file_exists(file_create_path($filepath))) {
$headers = module_invoke_all('file_download', $filepath);
if (in_array(-1, $headers)) {
return drupal_access_denied();
}
if (count($headers)) {
file_transfer($filepath, $headers);
}
}
return drupal_not_found();
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии