just a little question (PHP): I'm using
header('Content-Disposition: attachment; filename="downloaded.pdf"');
readfile('test.pdf');
to download a file under another filename. But in every script-example of this, there was "header('Content-type: application/pdf');" before this 2 lines in the code. I deletet the content-type-line and it still works fine. Do i need the missing line, when i just want to change the name of the downloaded file? Because therre are many filetypes, that can be downloaded in my website and so i would have to read the content-type before...
Thanks in advance for a short but understandable answer :)
Yes, you need it.
If you don't supply it, then PHP will default to outputting Content-Type: text/html
which will cause problems (at the very least) for browsers that only handle inline content (such as Mobile Safari).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.