Ik heb het volgende (slordige) downloadscript
Dit werkt goed, behalve als "bevestigen bij openen" uit staat bij bestandstypen, dan wordt hij dus meteen geopend, is er een header ofzo die de gebruiker forceert het bestand te downloaden?
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| $basedir = "../files/"; if ($_GET['filename']) { $saveas = basename($_GET['filename']); $fpath = $basedir . $saveas; $name = $saveas; send_file($name); } function send_file($name) { $status = FALSE; $path = "../files/".$name; if (!is_file($path) or connection_status()!=0) return(FALSE); header("Content-type: application/x-octet-stream"); header("Content-Disposition: inline; filename=\"".$name."\""); header("Content-length: ".(string)(filesize($path))); header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); if ($file = fopen($path, 'rb')) { while(!feof($file) and (connection_status()==0)) { print(fread($file, 1024*8)); flush(); } $status = (connection_status()==0); fclose($file); } return($status); } |
Dit werkt goed, behalve als "bevestigen bij openen" uit staat bij bestandstypen, dan wordt hij dus meteen geopend, is er een header ofzo die de gebruiker forceert het bestand te downloaden?
[ Voor 13% gewijzigd door Helmet op 28-03-2003 09:11 ]
Icons are overrated