|
1 <?php |
|
2 |
|
3 //$file = "6_licht.jpg"; |
|
4 //chmod($file,0444); // Nutzer www-data nicht gestattet, da von root in 'fhiiqm/test' erstellt! |
|
5 $file = $_SERVER["DOCUMENT_ROOT"] ."/fhiiqm/alprot/6_licht.JPG"; |
|
6 header ("Content-Type: application/force-download"); |
|
7 //header ("Content-Type: application/jpg"); |
|
8 //header('Content-Transfer-Encoding: binary'); |
|
9 header ('Content-Disposition: attachment; filename="licht.jpg"'); |
|
10 header("Content-Length: " . filesize($file)); |
|
11 readfile($file); |
|
12 //$fp = fopen("$file", "rb"); // geht genau so |
|
13 //fpassthru($fp); |
|
14 exit; |
|
15 |
|
16 function downloadFile( $fullPath ){ |
|
17 |
|
18 // Must be fresh start |
|
19 if( headers_sent() ) |
|
20 die('Headers Sent'); |
|
21 |
|
22 // Required for some browsers |
|
23 if(ini_get('zlib.output_compression')) |
|
24 ini_set('zlib.output_compression', 'Off'); |
|
25 |
|
26 // File Exists? |
|
27 if( file_exists($fullPath) ){ |
|
28 |
|
29 // Parse Info / Get Extension |
|
30 $fsize = filesize($fullPath); |
|
31 $path_parts = pathinfo($fullPath); |
|
32 $ext = strtolower($path_parts["extension"]); |
|
33 |
|
34 // Determine Content Type |
|
35 switch ($ext) { |
|
36 case "pdf": $ctype="application/pdf"; break; |
|
37 case "exe": $ctype="application/octet-stream"; break; |
|
38 case "zip": $ctype="application/zip"; break; |
|
39 case "doc": $ctype="application/msword"; break; |
|
40 case "xls": $ctype="application/vnd.ms-excel"; break; |
|
41 case "ppt": $ctype="application/vnd.ms-powerpoint"; break; |
|
42 case "gif": $ctype="image/gif"; break; |
|
43 case "png": $ctype="image/png"; break; |
|
44 case "jpeg": |
|
45 case "jpg": $ctype="image/jpg"; break; |
|
46 default: $ctype="application/force-download"; |
|
47 } |
|
48 |
|
49 header("Pragma: public"); // required |
|
50 header("Expires: 0"); |
|
51 header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
|
52 header("Cache-Control: private",false); // required for certain browsers |
|
53 header("Content-Type: $ctype"); |
|
54 header("Content-Disposition: attachment; filename=\"".basename($fullPath)."\";" ); |
|
55 header("Content-Transfer-Encoding: binary"); |
|
56 header("Content-Length: ".$fsize); |
|
57 ob_clean(); |
|
58 flush(); |
|
59 readfile( $fullPath ); |
|
60 |
|
61 } else |
|
62 die('File Not Found'); |
|
63 |
|
64 } |
|
65 //downloadFile("6_licht.jpg"); |
|
66 ?> |