Friday, December 12, 2003

Download box to save file in client pc

<%
Dim sFullFileName
sFullFileName = server.MapPath("/reporting") & "\photo.jpg"

Dim sFileName
sFileName = "photo.jpg"

Response.Contenttype = "application/x-unknown"
Response.Addheader "Content-Disposition", "attachment; filename=" & chr(34) & sFileName & chr(34)
Response.Binarywrite GetBinaryFile(sFullFileName)
'Response.Clear

Function GetBinaryFile(ByVal sFileSpec)
Const adTypeBinary = 1
Dim objStream
Set objStream = Server.Createobject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile sFileSpec
GetBinaryFile = objStream.read
Set objStream = Nothing
End Function
%>