I have an ASP page that does two things; writes to a log the users access to the page from a series of session variables created elsewhere on the site and then launches a file download. I want to capture whether the users selected "open" "save" or "cancel" and append that action to my log. Here is a snippet of the download code:
<%
' Force File Download
DIM f, fso, objStream
DIM strFileName, strFilePath, strFileSize, strFileType
strFileName="Setup.exe"
strFilePath= server.mappath("/PathToMyFile"
set fso=createobject("scripting.filesystemobject"
set f=fso.getfile(strfilepath)
strFileSize = f.size
set f=nothing: set fso=nothing
Const adTypeBinary = 1
Response.Clear
Set objStream = Server.CreateObject("ADODB.Stream"
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
strFileType = "application/exe" ' change to the correct content type for your file
Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName
Response.AddHeader "Content-Length", strFileSize
Response.Charset = "UTF-8"
Response.ContentType = strFileType
Response.BinaryWrite objStream.Read
Response.Flush
objStream.Close
Set objStream = Nothing
%>
I left the log generation stuff out of the snippet, but you get the idea. Any thoughts?
Scott
<%
' Force File Download
DIM f, fso, objStream
DIM strFileName, strFilePath, strFileSize, strFileType
strFileName="Setup.exe"
strFilePath= server.mappath("/PathToMyFile"
set fso=createobject("scripting.filesystemobject"
set f=fso.getfile(strfilepath)
strFileSize = f.size
set f=nothing: set fso=nothing
Const adTypeBinary = 1
Response.Clear
Set objStream = Server.CreateObject("ADODB.Stream"
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
strFileType = "application/exe" ' change to the correct content type for your file
Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName
Response.AddHeader "Content-Length", strFileSize
Response.Charset = "UTF-8"
Response.ContentType = strFileType
Response.BinaryWrite objStream.Read
Response.Flush
objStream.Close
Set objStream = Nothing
%>
I left the log generation stuff out of the snippet, but you get the idea. Any thoughts?
Scott