CMS  Version 3.9
download.inc
Go to the documentation of this file.
1 <?
2 /*
3  * Allow users to download/view a file uploaded through
4  * settings feature.
5  */
6 Fakoli::using("settings");
7 
8 $setting_id = checkNumeric($_GET["setting_id"]);
9 
11 
12 $dir = $config['uploadbase'] . DIRECTORY_SEPARATOR;
13 
14 trace("directory:dir:" . $dir, 3);
15 
16 $filepath = sanitizePath($dir . $setting->value);
17 $mimeType = getMimeType($setting->value);
18 
19 trace("attachment download: filepath:" . $filepath, 3);
20 $f = fopen($filepath, "r");
21 $size = filesize($filepath);
22 
23 header("Content-Disposition: attachment;filename=\"" . basename($setting->value) . "\"");
24 header("Content-Type: $mimeType");
25 header("Content-Length: $size");
26 
27 fpassthru($f);
28 fclose($f);
29 
30 session_write_close();
31 ?>
$dir
Definition: download.inc:40
$f
Definition: download.inc:46
$filepath
Definition: download.inc:42
$mimeType
Definition: download.inc:43
$size
Definition: download.inc:47
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
The Settings class provides components with a common API for specifying application settings and conf...
Definition: settings.inc:49
global $config
Definition: import.inc:4
$setting_id
Definition: download.inc:8
$setting
Definition: download.inc:10