Force file download of unknown file type using PHP

I am looking to force download a file from an external source using PHP headers. However, the file type may be NOTHING . How to make download all file types ?

I hope you can understand my question and what I'm trying to describe.

+5
source share
1 answer

You mean the HTTP headers, and you're looking for RFC 2616, http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html Content Distribution.

Send the following headers to download ALL files and types:

header('Content-Disposition: attachment; filename="name.ext"');
header('Content-Type: application/octet-stream'); // or application/force-download

echo $the_file_content;
exit;
+6
source

All Articles