function imagepicker_file_download in Image Picker 7
Same name and namespace in other branches
- 6.2 imagepicker.module \imagepicker_file_download()
Implements hook_file_download().
File
- ./
imagepicker.module, line 955 - @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function imagepicker_file_download($filepath) {
$imgbasedir = imagepicker_get_files_directory(TRUE);
$file = $imgbasedir . DIRECTORY_SEPARATOR . file_uri_target($filepath);
if (file_exists($file) & is_file($file)) {
// There is a file, and it's in our directory structure. So send it.
$mimetype = file_get_mimetype($filepath);
return array(
'Content-type:' . $mimetype,
);
}
else {
$path_parts = explode('/', $filepath);
if ($path_parts[0] == IMAGEPICKER_FILES_DIR) {
// The file is allegedly in our directory, but doesn't exist.
return -1;
}
}
}