0

I have a log folder on my ubuntu machine under /var/www/projectlog/logs which has zip versions of diffrent log files. I want to let users download these zip files from the webpage.

Is this possible to do in PHP ?

user3846091
  • 1,625
  • 6
  • 24
  • 29
  • 1
    possible duplicate of [How to force file download with PHP](http://stackoverflow.com/questions/7263923/how-to-force-file-download-with-php) – casraf Oct 26 '14 at 06:29
  • Check this - http://stackoverflow.com/questions/20162360/zip-and-download-files-using-php – pankaj Oct 26 '14 at 06:31
  • I don't understand, can you not just link to them? zips should automatically be downloadable. Since they look like they're under the public HTML directory, you can simply link to their location. If they're not accessible, you can create a symlink to every file or to the entire directory, and link to that on your webpage. If you want to mask the directory and control the downloads, you can use this Q&A: http://stackoverflow.com/questions/7263923/how-to-force-file-download-with-php and change the download URL to your files. – casraf Oct 26 '14 at 06:31

1 Answers1

0

Try this:

header('Content-disposition: attachment; filename=Resumes.zip');
header('Content-type: application/zip');
readfile("/var/www/projectlog/logs/<NAME_OF_ZIP>");

or just,

readfile("/var/www/projectlog/logs/<NAME_OF_ZIP>"); // as rest will be taken care automatically by browsers

Your PHP File owner should have read access to this path: /var/www/projectlog/logs/

Apul Gupta
  • 3,044
  • 3
  • 22
  • 30