Safari adding .exe to file downloads
I had a problem where downloading a file through Safari from our internal website was appending .exe to the filename. Changing the filename in Finder to the original file allowed everyone to work with the file as normal, but it was annoying.
There are a bunch of archived threads on this site with no real solution and very few helpful comments. Thus this post:
Solution
The problem is the header information associated with our file download. We download a CSV file but call it an XLS. We also send header information calling it an XLS so that Excel will automatically open the file.
Although it does not specifically say anywhere on the web, inferring from the ages of posts through Google, it looks like the content type of "application/x-msdownload" has been superseded by "application/vnd.ms-excel". Most browsers remain backward-compatible (we don't have the error with Chrome) but it seems that newer Safari browsers no longer respect "application/x-msdownload".
We changed the following on our server, since the file download was being generated via PHP.
Code
Our original code read:
header("Content-type: application/x-msdownload");
The code was changed to read:
header("Content-type: application/vnd.ms-excel");
Now it works correctly.
Safari-OTHER, Mac OS X (10.7.2)