I have had reported on occasions when Safari on Mac is downloading a PDF from one of our sites it will append .EXE to the end of the file. The MIME type is correctly set to be pdf but it still does it occasionally.
I have found http://support.apple.com/kb/TA24293 which seems to indicate that this is a known issue with Safari on Mac however as official as this is (Since it is from Apple themselves) our clients don't seem to want to believe it. So I want to know if there is a solution to this problem?
I say "occasionally" because we have some Macs that this is happening on and some it's not. So maybe it's a setting or something, it downloads perfectly fine in IE, Firefox, Chrome and even downloads fine on mobile Safari. It is just Mac Safari.
Best Answer
HTTP Header: Content-Disposition
Have the server include an additional Content-Disposition header when serving the PDFs:
This provides the browser with a strong suggestion for the desired filename and suffix. See How to encode the filename parameter of Content-Disposition header in HTTP? for a discussion about limitations and implementing this feature.
MIME Type
Additionally, make sure the server's PDF mime type in the
Content-Type:
header is set correctly. There are variations in use.application/pdf
is the recommended type.Test with
curl
Use
curl -I http://example.com/mypdf.pdf
to test and ensure the correct headers are returned by your server. curl can provide credentials to work as a logged in user.Potentially related question: When sending headers to download a PDF, Safari appends .html