[ale] apache problem

Neal Rhodes neal at mnopltd.com
Wed Jan 12 16:04:21 EST 2011


Yeah, that sounds familiar.  The real booger was figuring out for each
browser what it wanted to see in the headers for those various file
types. 

On Wed, 2011-01-12 at 15:07 -0500, Mike Harrison wrote: 

> > It's a moderate booger to write the thing that spits back the file
> > inline, since we might have .pdf files, .html files, text files, and I
> > recall we had to do content headers appropriately.
> 
> This is fairly easy to do in PHP, and I expect other languages as well.
> 
> This is the two fragments from a bigger program that demonstrate a method.
> 
> #FRAGMENT 1
>      $file_extension = strtolower(substr(strrchr($filename, "."), 1));
>      switch ($file_extension) {
>          case "pdf":
>              $ctype = "application/pdf";
>          break;
>          case "csv":
>              $ctype = "application/text";
>          break;
>          case "xls":
>              $ctype = "application/vnd.ms-excel";
>          break;
>          default:
>              $ctype = "application/force-download";
>      }
> 
> 
> 
> #FRAGMENT2:
> 
>      header("Pragma: public");
>      header("Expires: 0");
>      header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
>      header("Cache-Control: private", false);
>      header("Content-Type: $ctype");
>      header("Content-Disposition: attachment; filename=\"" . basename($as) . "\";");
>      header("Content-Transfer-Encoding: binary");
>      header("Content-Length: " . @filesize($filename));
> #    set_time_limit(20);
>      ob_clean();
>      flush();
>      @readfile("$filename") or die("File not found.");
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20110112/e93f3dae/attachment-0001.html 


More information about the Ale mailing list