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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a file download log

Status
Not open for further replies.

dkn

Programmer
Oct 11, 2000
60
0
0
US
Hi

I'm currently developing a Document Management System, and one of the requirements is to keep a log of all files that are downloaded and uploaded to the server. I'm having problems with creating a download log.

The document detail are displayed in a table, with the download activated by clicking an image, which then displays the standard file download dialog box. I have been trying to use the onclick event of the image to call a function which will write to the log file. However this doesn't appear to work. Here is the code i'm trying to use

<td width=&quot;38&quot; align=&quot;center&quot;><a href=&quot;<%=MySet(&quot;DocURL&quot;)%>&quot;><img src=&quot;images/sdload_normal.jpg&quot; alt=&quot;Download this Document&quot; name=&quot;<%=image_name%>&quot; width=&quot;34&quot; height=&quot;35&quot;
onclick=&quot;WriteLog('<%=MySet(&quot;DocID&quot;)%>', '<%=MySet(&quot;DocURL&quot;)%>')&quot;></a></td>

'WriteLog Function
Sub WriteLog(DocID, DocURL)

set myset = server.createobject(&quot;ADODB.Recordset&quot;)

MySet.Open &quot;tblTransferLog&quot;, MyConnection, 1, 2, adCmdTableDirect
MySet.addNew
MySet(&quot;DocID&quot;) = DocID
MySet(&quot;MasterFileName&quot;) = upl.ExtractFileName(DocURL)
MySet(&quot;PDFFileName&quot;) = &quot;N/A&quot;
MySet(&quot;TransferType&quot;) = &quot;DLoad&quot;
MySet(&quot;TransferDate&quot;) = Now()
MySet(&quot;CDSID&quot;) = Request.ServerVariables(&quot;AUTH_USER&quot;)
MySet.Update

MySet.close
Set MySet = Nothing

End Sub

Any other ideas how i can approach this??

Thanks
 
Yes this is preatty easy using a download.asp page for example

your list should have this, where the file name is the name of the file you wish to download.

<a href=&quot;download.asp?filename=<%=filename%>&quot;><img src=&quot;images/sdload_normal.jpg&quot; alt=&quot;Download this Document&quot; width=&quot;34&quot; height=&quot;35&quot;></a>

and the download.asp
<%
filename=Request(&quot;filename&quot;)
'now write the log
Response.AddHeader &quot;Content-type&quot;,&quot;application/x-msdownload&quot;
Response.AddHeader &quot;Content-Disposition&quot;,&quot;attachment; filename=&quot;&filename&&quot;;&quot;
'the name how would be saved
filepath=Server.MapPath(filename)
data=Server.CreateObject(&quot;ADODB.Stream&quot;)
data.Open
data.Type = 1 'Binary
data.LoadFromFile filepath
dim buffer
data.Write buffer
Response.Write buffer
%>


This shiould do the trick, it's not 100% runable but the code lines should be 100% ok

________
George, M
 
Thanks, I'll give it a try.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top