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

Record Downloaded

Status
Not open for further replies.

3443232

Technical User
Dec 18, 2003
6
US
I am creating a site where visitors can download files. I would like to record in my database how many time the file has been download.
Can someone help?
Thanks
 
have the link to the download link to a page that runs an update query first

<cfquery name = &quot;lastDL&quot;...>
select downloadCount, fileLocation from table where fileID = '#url.fileID#'
</cfquery>
<cfset newCount = lastDL.downloadCount + 1>
<cfquery...>
update table set downloadCount = 'newCount' where fileID = '#url.fileID#'
</cfquery>
<cflocation url = &quot;#lastDL.fileLocation#&quot;> <--- assuming the file url is stored in the DB

thereptilian120x120.gif
 
This will tell you how many download ATTEMPTS there are. Whether or not the download completes or is successfull there's really no way to know.

Hope This Helps!

Ecobb

&quot;Alright Brain, you don't like me, and I don't like you. But lets just do this, and I can get back to killing you with beer.&quot; - Homer Simpson
 
You could also do this in one query. Since you're only returning one row, it shouldn't make that much of a difference, but that all depends on how many files/visitors you have.

<cfquery name=&quot;UpdateCount&quot; ...>
update table
set downloadCount = downloadCount + 1
where fileID = '#url.fileID#'
</cfquery>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top