I can download pdf files stored outside the web root, like so:


/* DOWNLOADING A FILE FROM A DIRECTORY OUTSIDE THE ROOT.
We'll be outputting a PDF */
header('Content-type: application/pdf');
/* It will be called testpdf.pdf */
header("Content-Disposition: attachment; filename=testpdf.zip");
/* path to outside root directory */
include("/mypath/testpdf.zip"); 

No problems there - BUT if I try the same thing with a zip file in the following code, I just get an empty file and the error message '...no zip file or part of a spanned zip'.
I've tried changing the application to x-zip and x-zip-compress etc, nothing works:


/* DOWNLOADING A FILE FROM A DIRECTORY OUTSIDE THE ROOT.
We'll be outputting a zip */
header('Content-type: application/zip ');
/* It will be called test.zip */
header("Content-Disposition: attachment; filename=test.zip");
/* path to outside root directory */
include("/mypath/test.zip"); 

    do not [man]include[/man] the target file. use [man]readfile[/man] instead. be sure to call [man]exit[/man] after [man]readfile[/man].

      thanx - that helped a wee bit.
      it took an entire day of trial an error but this is what worked:
      (the pdf version in the first post proved to be unstable, so use this and change to pdf where necessary.)

      
      /* DOWNLOADING A FILE FROM A DIRECTORY OUTSIDE THE ROOT.
      We'll be outputting a zip */
      header('Content-type: application/zip');
      /* It will be called test.zip */
      header("Content-Disposition: attachment; filename=test.zip");
      header("Expires: 0");
      header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
      /* path to outside root directory */
      readfile('/mypath/test.zip');
      exit; 
      
      
        Write a Reply...