[ciapug] fpassthru file download

Eric Junker eric at eric.nu
Wed Dec 5 15:59:00 CST 2007


Try removing your Cache-Control header and see if that makes a 
difference. This site has more info on this topic: http://tinyurl.com/2nmwn4

Eric

Barry Von Ahsen wrote:
> so I had to revisit this, and it seems a lot of people have this 
> problem, but haven't found a solution.
> 
> I want users to download a file that preferably lives outside of the 
> webroot.  it works fine in FF and IE7, but IE6 won't pick up the file 
> name I specify, it wants to name it my page name (download.php) - I 
> accept that IE6 SP2 will force a download, I just want the name to be 
> right.  anybody fixed this?
> 
> 
> here's my code:
> 
> $ext = pathinfo($thefile,PATHINFO_EXTENSION);
> $file = $download_dir.$thefile;
> if($fh = fopen($file,"rb")) {
>     /*if(function_exists(mime_content_type)) {
>         header("Content-Type: ".mime_content_type($file));
>     } else {*/
>         switch($ext) {
>             case "pdf": header("Content-Type: application/pdf"); break;
>             case "doc": header("Content-Type: application/msword"); break;
>             case "csv": header("Content-Type: application/msexcel"); break;
>             case "exe": header("Content-Type: 
> application/force-download"); break;
>             case "mp3": header("Content-Type: audio/mpeg"); break;
>             case "txt": header("Content-Type: text/plain"); break;
>             case "zip": header("Content-Type: application/zip"); break;
>             default: header("Content-Type: application/force-download"); 
> break;
>         }
>     //}
>     header("Content-Disposition: attachment; filename=\"$thefile\"");
>     header("Content-Length: " . filesize($file));
>     header('Cache-Control: public');
>     header('Pragma: public');
>     fpassthru($fh);
>     exit();
> }
> _______________________________________________
> ciapug mailing list
> ciapug at cialug.org
> http://cialug.org/mailman/listinfo/ciapug



More information about the ciapug mailing list