I have a web app which performs a character encoding conversion on .ssa files (SubStation Alpha – subtitle files basically). The MIME type of these files is text/plain. When the app performs the conversion it creates a link to download the new file. In Safari this works perfectly. However in Chrome when you click the download link it attempts to save the file as download.txt no matter what the actual filename is. In Firefox (beta) it tries to save it as something like kP3844h1.txt.part. How can I tell these browsers just to use the filename that is linked? In all cases the contents of the file is correct, it’s just the name in the browser’s “Save As…” dialog that gets screwed up.
Currently my .htaccess looks like:
AddType text/plain ssa
<Files *.ssa>
#ForceType application/octet-stream
Header set Content-Disposition attachment
</Files>
I’ve tried with both of the <Files> lines uncommented, and with either one commented on its own, but none of those options gives me the solution I’m looking for.
Also, the app is written in PHP, so if there’s something I could be doing in the PHP code instead of messing with the .htaccess, I’m open to suggestions.
Use
Content-Disposition attachment; filename="$actual_filename.txt"as header. Replace$actual_filename.txtby the actual name of the file. I have no idea if this is possible in the Apache configuration, but if you pipe the files through PHP, you might be able to set the header with the header function.