Could someone help me with a little PHP problem?
This is my code:
$mr = mysqli_fetch_assoc($ms);
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename="" . basename($mr['flink']) . """);
readfile($mr['flink']);
header("Location: ref.php?action=viewdeti&id=".$_GET['id']);
Where $mysqli is my mysql connection and $id is $_GET[‘id’].
$mr[‘flink’] is link to file hosted on my server.
Now the problem:
When the code is hosted on my server the code runs successful and allow to download the file from localhost and redirect me to correct page.
When the code is hosted on web server hosting and when run the script don’t download the file hosted on the web server but opens the file in browser as code and doesn’t redirect me.
I will attach photos to see the problem in fact.
The versions on server’s apache, mysql, php is same as on the localhost.
The files for downloading are *.pdf
Please if you have any idea, help me.
Thanks in advance.
Best Regards,
Rossen
2
Answers
Now already working properly. I recompile it via UTF8 without B
And now it's ok.
Thanks all for help.
Each line has comment which is explained.
Along with the above, make sure that the actual file has .pdf extension. It somehow appears that the file is missing the extension on your remote server.