This sample template covers file uploads. It has file size and mime
type checking.
You'll need cfdirectory to list the file contents, and users can
download from that list via a link to a custom tag that uses cfcontent
to push down the file to them.
This version of that tag will send anything down with a save/open
dialog:
<cfparam name="attributes.FilePath" default="" TYPE="string">
<cfparam name="attributes.FileName" default="" TYPE="string">
<cfif Len(attributes.FileName)>
<cfset
variables.FileToPush=attributes.FilePath&attributes.FileName>
<cfif FileExists(variables.FileToPush)>
<cfheader
name="Content-Disposition"
value="attachment;
filename=#attributes.FileName#">
<cfcontent
type="application/unknown"
file=#variables.FileToPush#>
<cfelse>
<center><h1>Sorry, File Does Not Exist</h1></center>
<cfabort>
</cfif>
<cfelse>
<center><h1>No File Selected</h1></center>
<cfabort>
</cfif>
This one, almost identical, will open a PDF in the browser (in a
non-infringing manner, I might add)
<cfparam name="attributes.FilePath" default="" TYPE="string">
<cfparam name="attributes.FileName" default="" TYPE="string">
<cfif Len(attributes.FileName)>
<cfset
variables.FileToPush=attributes.FilePath&attributes.FileName>
<cfif FileExists(variables.FileToPush)>
<cfheader
name="content-disposition"
value="inline; filename=#attributes.FileName#">
<cfcontent
type="application/pdf"
file=#variables.FileToPush#>
<cfelse>
<center><h1>Sorry, File Does Not Exist</h1></center>
<cfabort>
</cfif>
<cfelse>
<center><h1>No File Selected</h1></center>
<cfabort>
</cfif>
Hope this helps,
--------------------------------------------
Matt Robertson [EMAIL PROTECTED]
MSB Designs, Inc. http://mysecretbase.com
--------------------------------------------
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

