Reputation: 101
I am having trouble with Chrome and the name Chrome gives a PDF on download.
The file name as read by Chrome:
The name of the file when I click the download button: ControlFile.php
I have narrowed it down to an issue with Chrome PDF Viewer. Altering the headers and URL bar have no effect. If I disable the plugin, it downloads with the correct name.
I have been unable to find a way to change the name that gets generated. Is anyone able to assist me in this?
As requested, here is the code where the content is being named:
header('content-type:application/pdf');
header('Content-Disposition: inline; filename='.$name . '.' . $format);
echo $output;
I checked the headers before the echo using headers_list()
. The issue is only for displaying PDFs on screen and downloading them using the button that appears in chrome, not for when downloading without displaying.
Upvotes: 1
Views: 4071
Reputation: 89
Just add the filename to end of URL, it works fine for me
ex:
ControlFile.php/Myfilename.pdf
Upvotes: 1
Reputation: 22158
I think you've missed the quotes and the type of the content (attachment):
header('Content-Disposition: attachment; filename="'.$name . '.' . $format.'"');
Upvotes: 1