-1

In PHP I know how to read a file. However, I want the script to be able to return the contents of the file to be downloaded.

For example: http://example.com/myfiles.php?source=images.zip I need myfiles.php to returns the headers of zip file followed by its contents.

Termis
  • 67
  • 1
  • 10
  • 1
    There is an abundance of tutorials, articles and questions here on stackoverflow on this question. Please show a little bit more effort before asking a question. – Louis Huppenbauer Nov 14 '12 at 16:42
  • @LouisH. Sorry I realized that my question is unique, because I did not find something talking about PHP and it when I write it. I noticed the search box later. You know when someone thinking and need something she may forget other things – Termis Nov 14 '12 at 16:46

1 Answers1

3

You need to change the headers in myfiles.php script file so it will force it to download:

header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=images.zip");
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: binary");
Vasi Puica
  • 111
  • 4