> P.S. If you want clean downloads using the
<cfcontent...> method there
are some headers you would probably want to set as well to
inform the
browser the proper file name and extension of the download.
This is
well discussed and blogged all over the internet and full
examples are
plentiful.
Ian, do you mean like the <cfheader...> tag I posted in
my original reply?
<cfheader name="Content-Disposition" value="inline;
filename=document.doc">
The full code I use to push files to users is as follows.
Save this as getFile.cfm, update the fileshareroot variable, update
the code that checks that the user has valid access rights, and
access by sending a user the url:
http://myserver.com/getFile.cfm?filename=myFileToGet.ext
<cfparam name="filename">
<cfset fileshareroot="/my/fileshare/root">
<!--- verify user can access this file. --->
<cfset validAccess = false>
<cfif userCanAccess> <!--- must be customized
--->
<cfset validAccess = true>
</cfif>
<cfif not validAccess>
You are not authorized to view this document.
<cfabort>
</cfif>
<!--- verify document exists --->
<cfif not FileExists("#FileshareRoot#/#filename#")>
The document you requested doesn't exist.
<cfabort>
</cfif>
<!---
// getContentTypeFor() uses mime types from
// JAVA_HOME/lib/content-types.properties or
// JAVA_HOME/jre/lib/content-types.properties
--->
<cfset URLConnection =
CreateObject("Java","java.net.URLConnection")>
<cfset myMimeType =
URLConnection.getFileNameMap().getContentTypeFor(filename)>
<!--- if the file extension isn't found in
JAVA_HOME/jre/lib/content-types.properties, then myMimeType isn't
defined. Set it to text/plain --->
<cfif not isDefined("myMimeType")><cfset myMimeType
= "text/plain"></cfif>
<cfheader name="Content-Disposition" value='inline;
filename="#filename#"'>
<cfcontent type="#myMimeType#" deletefile="No"
file="#FileshareRoot#/#filename#">