function webform_file_download in Webform 5.2
Same name and namespace in other branches
- 8.5 webform.module \webform_file_download()
- 5 webform.module \webform_file_download()
- 6.3 webform.module \webform_file_download()
- 6.2 webform.module \webform_file_download()
- 7.4 webform.module \webform_file_download()
- 7.3 webform.module \webform_file_download()
- 6.x webform.module \webform_file_download()
Implementation of hook_file_download().
Only allow users with view webform submissions to download files.
File
- ./
webform.module, line 303
Code
function webform_file_download($file) {
$file = file_check_location(file_directory_path() . '/' . $file, file_directory_path() . '/webform/');
if ($file && user_access('access webform results')) {
$info = image_get_info(file_create_path($file));
if (isset($info['mime_type'])) {
$headers = array(
'Content-type: ' . $info['mime_type'],
);
}
else {
$headers = array(
'Content-type: force-download',
'Content-disposition: attachment',
);
}
return $headers;
}
}