<cfif isdefined ("url.Action")>
<!---
Test the file size
--->
<cfif val(cgi.content_length) gt 10240000>
<cfset variables.Success="Too Big! No dice.">
<cfelse>
<cfset request.AcceptAudio=
"audio/mp3">
<!---
now try to upload the file
--->
<cftry>
<cffile
action="Upload"
filefield="FileContents"
destination="D:\websites\thewikiband.net\songs\"
nameconflict="OVERWRITE"
accept="#request.AcceptAudio#">
<cfset variables.Success="Uploaded.">
<cfcatch type="Application">
<!---
something went wrong. Was it a mime type failure?
--->
<cfif isdefined("cfcatch.MimeType")>
<!---
yes it was. show the friendly error message.
--->
<cfif not ListContains
(request.AcceptAudio,cfcatch.MimeType)>
This type of file is not allowed for upload.
<cfelse>
<!---
Hmmm. the mimetype is there but the file was on the
list. Better dump out the whole error message.
--->
<cfoutput>
<b>Error</b><br>
#cfcatch.Message#
#cfcatch.Detail#
</cfoutput>
</cfif>
<cfelse>
<cfoutput>
<b>Error</b><br>
#cfcatch.Message#
#cfcatch.Detail#
</cfoutput>
</cfif>
<cfabort>
</cfcatch>
<cfcatch type="Any">
<cfoutput>
<b>Error</b><br>
#cfcatch.Message#
#cfcatch.Detail#
</cfoutput>
<cfabort>
</cfcatch>
</cftry>
</cfif>
</cfif>
<!---
Display the form
--->
<html><head><title>Uploader Test</title></head><body>
<cfif isdefined ("url.Action")>
<cfoutput>
Your file was #variables.Success#
</cfoutput>
</cfif>
<cfoutput>
<form
action="#cgi.script_name#?Action=Y"
method="post"
enctype="multipart/form-data">
</cfoutput>
Source File Name:<BR>
<input
name="FileContents"
type="FILE"
size="45"><br>
<input
type="submit"
value="Upload File">
</form>
|