wants to make a redirect to a page to a file
function downloadFile($url) {
... // save info to database
$path = ..; // checking if the file is on the local server
if(empty($path) === false) {
// download file from local server - it works
header("Content-Description: File Transfer");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"". basename($path) ."\"");
readfile($path);
exit;
}
// downloading a file from another server - it does not work, $url is 100% good
header("Location: " . $url);
exit;
}
but the file is not thrown on the screen, I see this file only in the tab "Network"
eq:
...file?id=123 // first page run header("Location: " . $url); exit;
and redirect to page from another server
...download_file?id=123 // status 302
...file.pdf // status 302
...file.pdf // status 200
header for last page
HTTP/1.1 200 OK
Date: Wed, 30 Dec 2020 15:45:21 GMT
Server: Apache
Last-Modified: Wed, 30 Dec 2020 16:38:38 GMT
ETag: "1a8f32-5b7af7b443bf7"
Accept-Ranges: bytes
Content-Length: 1740594
Content-Disposition: attachment
Content-Type: application/force-download
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
why it doesn't display the file on the screen? why it doesn't start downloading? there is only info in the tool (tab Network)