Ah yes, if I remove the transaction block it works. I need to make sure that in between querying the db for the file details and updating the download count another 'download' doesn't sneak in, hence the use of cftransaction. If I complete the transaction block before serving the file I'll be spanning the <cfif> that checks if a record is valid so my code would end up looking like:
<cftransaction>
<!--- retrieve the file details based fileID passed to me --->
<cfquery datasource="****" name="filedetails">
select *
from tblFiles
where FileID = <cfqueryparam cfsqltype="cf_sql_varchar" maxlength="35" value="#url.fileID#">
</cfquery>
<!--- make sure we retrieve a valid record --->
<cfif filedetails.recordcount>
<cfset newdownloadcount = filedetails.downloadcount + 1>
<cfquery datasource="****" name="updatecount">
update tblFiles
set downloadcount = <cfqueryparam cfsqltype="cf_sql_integer" value="#newdownloadcount#">
where FileID = <cfqueryparam cfsqltype="cf_sql_varchar" maxlength="35" value="#url.fileID#">
</cfquery>
</cftransaction>
<!--- fake header so browsers don't try to download as current template name --->
<cfheader name="content-disposition" value="attachment;filename=#filedetails.filename#">
<!--- serve the file up with CFCONTENT --->
<cfcontent file="c:\****\#filedetails.path#\#filedetails.filename#" type="application/unknown">
</cfif>
Any ideas?
-----Original Message-----
From: Stephen Moretti [mailto:[EMAIL PROTECTED]]
Sent: 28 May 2004 09:58
To: [EMAIL PROTECTED]
Subject: Re: [ cf-dev ] serving files with cfcontent
> It sends the file for download but doesn't update the download count
> in the db, if I comment out the cfheader/cfcontent block it updates
> the Db so it's not a code bug.
>
Its probably because you're serving the file inside the cftransaction.
Try completing the transaction before serving the file.
Stephen
--
These lists are syncronised with the CFDeveloper forum at http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by activepdf.com*
*Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
*Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*
To unsubscribe, e-mail: [EMAIL PROTECTED]
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed Scanning Services - powered by MessageLabs. For further information visit http://www.mci.com
**********************************************************************
Copyright ERA Technology Ltd. 2004. (www.era.co.uk). All rights reserved. The information supplied in this Commercial Communication should be treated in confidence.
No liability whatsoever is accepted for any loss or damage
suffered as a result of accessing this message or any attachments.
**********************************************************************
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed Scanning Services - powered by MessageLabs. For further information visit http://www.mci.com