Hej
Sidder og arbejder på en download forcer...
Og efter jeg endelig fik den til at fungere og hente 'hele' filen ned.
Så virker filen ikke efter download...
Har testet 2 forskellige xp comps, både i ff og IE 7.
- <?php
- function getFile($file,$dir) {
-
-
- $baseDir = "/home/christian.wid.ots.dk/public_html/data";
- $dirConverted = str_replace("@","/",$dir);
- $fullPath = $baseDir.$dirConverted."/".$file;
- $type = mime_content_type($fullPath);
- $filesize = filesize($fullPath);
- if ($filesize == false OR !is_numeric($filesize)) {
- $filesize = strlen($fullPath);
- }
- if (empty($type)) {
- $type = 'application/octet-stream';
- }
-
- $this->ob_clean_all();
- #header("Content-Type: application/octet-stream");
- #header("Content-Length: " . $filesize . "");
- #header("Pragma: public");
- #header("Expires: 0");
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
- header("Cache-Control: private");
- header("Content-Disposition: filename=".$fullPath);
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // some day in the past
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- header("Content-type: application/x-download");
- header("Content-Disposition: attachment; filename=".$fullPath);
- header("Content-Transfer-Encoding: binary");
-
-
- readfile($fullPath);
- exit;
- }
-
- function ob_clean_all () {
- $ob_active = ob_get_length () !== false;
- while($ob_active) {
- ob_end_clean();
- $ob_active = ob_get_length () !== false;
- }
-
- return true;
- }
- ?>
Indlæg senest redigeret d. 17.09.2008 09:41 af Bruger #1742