>>In Claude's original question, it doesn't appear he's using CFCONTENT:

Yes I am.
Here is a summary of the code in application.cfm:
You can see that the requested file is never executed nor intended to.
The only purpose of the .cfm extension is to force the execution of the 
application.cfm
Here, the code in application.cfm is only used to count the nb of times each 
document was requested.
The advantages of the method are 1. simplicity, 2. it is compatible with 
previous documents uploaded with true .pdf and .doc extension prior we 
implemented this counting scheme.
The only problem which we didn't figure out at the time is that the template is 
compiled BEFORE application.cfm is called.
It could have been AFTER as well and CF would still work the same.
In pure logic, there is no use to compile a template before it is certain it 
will be executed.
There are other cases templates are compiled for nothing, ie:
application.cfm verifies a user is logged, if not, it <CFLOCATIONs the user 
toward the loggin script, then the template he called is never executed.
CF could have very well been designed so that templates are compiled only if 
executed.
Now I know it is not the case.

<!--- Get the document file name --->
<CFQUERY NAME="getDoc" DATASOURCE="#application.applicationName#">
   SELECT docId,
     fileName,
     localName
   FROM docs
   WHERE localName = '#listLast(cgi.script_name, "/")#'
</CFQUERY>
<CFIF getDoc.recordCount GT 0>
<CFIF fileExists("#application.webRootDir#contentDocuments\#GetDoc.localName#")>
<!--- count nb of time document was opened --->
<CFQUERY DATASOURCE="#application.applicationName#">
       UPDATE docs
         SET nblu = nblu+1
       WHERE docId = #getDoc.docId#
</CFQUERY>

<!--- send document to the reader --->
<CFHEADER NAME="Content-disposition" 
VALUE='Attachment;filename="#getDoc.fileName#"'>
<CFHEADER NAME="Content-Type" VALUE="application/octet-stream">
<CFCONTENT TYPE="application/octet-stream" 
FILE="#application.webRootDir#contentDocuments\#GetDoc.localName#">
<CFABORT>
<CFELSE>
<CFSET error = "This file doesn't exist">
</CFIF>
<CFELSE>
<CFSET error = "This file doesn't exist">
</CFIF>
<CFIF error NEQ "">
<CENTER><IMG SRC="../images/header.png"
                 WIDTH="790" HEIGHT="135" BORDER="0" ALT="">
<CFOUTPUT><H2>#erreur#</H2></CENTER></CFOUTPUT>
</CFIF>
<CFABORT>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:345570
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to