Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validating a successful file download.

Status
Not open for further replies.

smugg

IS-IT--Management
Mar 5, 2001
30
US
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=&quot;Setup.exe&quot;
strFilePath= server.mappath(&quot;/PathToMyFile&quot;)

set fso=createobject(&quot;scripting.filesystemobject&quot;)
set f=fso.getfile(strfilepath)
strFileSize = f.size
set f=nothing: set fso=nothing
Const adTypeBinary = 1
Response.Clear
Set objStream = Server.CreateObject(&quot;ADODB.Stream&quot;)
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
strFileType = &quot;application/exe&quot; ' change to the correct content type for your file
Response.AddHeader &quot;Content-Disposition&quot;, &quot;attachment; filename=&quot; & strFileName
Response.AddHeader &quot;Content-Length&quot;, strFileSize
Response.Charset = &quot;UTF-8&quot;
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
 
the &quot;open&quot; &quot;save&quot; or &quot;cancel&quot; are live actions so if you can capture those events at all you'ld have to capture it with javascript and then append the captured event to your logfile.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top