I want to require a file to be downloaded upon the user visiting a web page with PHP. I think it has something to do with file_get_contents
, but am not sure how to execute it.
$url = "http://example.com/go.exe";
After downloading a file with header(location)
it is not redirecting to another page. It just stops.
A modification of the accepted answer above, which also detects the MIME type in runtime:
Or, when the file is not openable with the browser, you can just use the
Location
header:try this: