Thanks for the code , maybe im being a little thick , but there is no mention of the
oUtilityObject referenced within this example code.
I managed to work it out using this article and another from here ..
http://www.developerfusion.com/show/2542
My working version of these two pieces of code is as follows ...
Code: <%
Function getBinaryFile(strFilePath)
Dim TypeBinary, oStream
TypeBinary = 1 ' Indicates a binary file
' Create the object
Set oStream = Server.CreateObject("ADODB.Stream")
' Open our file
oStream.Open
' Retreive binary data from the file
oStream.Type = TypeBinary
oStream.LoadFromFile strFilePath
' Return the binary data to the caller
getBinaryFile = oStream.read
' Destroy the ADO object
Set oStream = Nothing
End Function
sServerFile = Server.MapPath("/therealfilelocation/private/CTC012.pdf")
'sFile = "CTC012.pdf"
Response.Buffer = True
Response.Clear
' I want the file displayed within the browser so dont specify a filename
'Response.AddHeader "content-disposition", "attachment; filename=" & sFile
Response.ContentType = "application/pdf"
Response.BinaryWrite getBinaryFile(Server.MapPath("/therealfilelocation/private/CTC012.pdf"))
Response.end
%>
It is worth noting that when I specified a filename if the user chose the "open file" option instead of the "save file" option when prompted by Internet Explorer Acrobat reader displays the error "File Not Found" after IE has downloaded the data.
To get around this and to make the page look nicer , i commented out the filename part.
This means Internet Explorer Opens it via Acrobat in the browser (if configured).
I have not tested MACS or other Browsers yet.
Hope this helps someone.