Closed (fixed)
Project:
Private Download
Version:
6.x-1.2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Mar 2011 at 13:15 UTC
Updated:
3 Apr 2011 at 20:26 UTC
As the filename is not passed to the header in
function private_download_file_download($filepath) {
$header = array('Content-Type: '. file_get_mimetype($filepath), 'Content-Length: '. filesize(file_create_path($filepath)));
// add additional file header attributes
return array_merge($header, explode("\n", variable_get('private_download_header', "Content-Transfer-Encoding: binary\nCache-Control: max-age=60, must-revalidate")));
}
browsers like Firefox don't display a filename in their "Opening" dialog when downloading a file. Also the application opening the file on the client displays a strange partially random filename like e.g. kt0aXIXi.pdf-1.part as the name of the downloaded and opened file.
This can be avoided (at least in my case on 2 different servers) by setting Content-Disposition additionally like in
$header = array('Content-Type: '. file_get_mimetype($filepath),
'Content-Length: '. filesize(file_create_path($filepath)),
'Content-Disposition: attachment; filename="'. basename($filepath).'"');
Comments
Comment #1
richardmetzger commentedI've learned that instead of
Content-Disposition: attachment; filename="'. basename($filepath).'"'it would be better to use
Content-Disposition: attachment; filename="'. mime_header_encode(basename($filepath)).'"'Comment #2
johnhanley commented@richardmetzger,
Thanks for your original post and follow-up. I'll be sure to include your suggestion in the next release, which hopefully we be within the next week or two.
John (aka. Bacteria Man)
Comment #3
johnhanley commentedThis fix has been applied to the dev version and will be part of the next release. Thanks!