Persits AspUpload, Content-type and Safari

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:

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 3.0.0.2 on a Hostway Windows 2003 Gold plan, shared hosting.

Posted by creacog

Product Owner/Manager; Digital Project Manager, ex-Developer Available for Product Owner roles

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.