A quick note for anyone using legacy server-side classic ASP and the Persits AspUpload component‘s sendBinary to download files to Apple’s Safari browser.
I ran into a problem recently where by Safari was appending “.html” to the file name of all downloads sent via the component. e.g. test.pdf would download as test.pdf.html. There are a couple of mentions on the apple support forums:
- Safari: Downloaded file’s filename may have an additional extension
- Topic : Safari adds .html extension to common downloads
PDF files downloaded directly did not suffer this problem – suggesting that the server’s mime types seem ok. Other browsers did not suffer this problem. However the problem has to be server-side. i.e. the download via the script is being sent with Content-type text/html instead of application/pdf no matter what arguments I add to the sendBinary call.
The solution seems to be to manually set the script’s Response.contentType value. i.e. the following test script works…
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% FILEPATH = "D:\WWWRoot\sitepath\www\pdftest\TEST.pdf" Dim upl Set upl = Server.CreateObject("Persits.Upload.1") Response.ContentType = "application/pdf" upl.sendbinary FILEPATH, True, "application/pdf", True %>
In my case this is using AspUpload version 188.8.131.52 on a Hostway Windows 2003 Gold plan, shared hosting.