Are you using CFFile to upload the files? If so, it returns a
variable CFFILE.ServerFileExt
Check that variable to see if matches one of the allowed extensions.
If not, immediately delete the file, and present whatever error
message you wish to show.
Something like this (note syntax not correct - just pseudocode)
<cfset variables.allowedtypes = "jpg, pdf, doc, docx, rtf, txt">
<cftry>
<cffile
action = "upload"
destination = "full pathname"
fileField = "form field"
accept = "#variables.allowedtypes#"
attributes = "file attribute or list"
mode = "permission"
nameConflict = "behavior"
result = "result name">
<cfcatch type="ANY">
<cfif not findnocase(CFFILE.ServerFileExt,variables.allowedtypes)>
if file exists delete it then Show error message
</cfif>
</cfcatch>
</cftry>
On Fri, Jul 8, 2011 at 8:34 AM, Adam Parker <[email protected]> wrote:
>
> I have a form that visitors use to nominate colleagues for an award. Users
> must upload documents to support their nomination. I have the MIME type for
> the uploaded documents restricted to PDF, DOC, DOCX, RTF, or TXT files. I
> would like to have help in better understanding how I may produce a friendly
> error message to the user if the incorrect file format is uploaded. I am
> using a form validation technique I learned from Ben Nadel where an array is
> used to hold the errors then display them to the user. The full form can be
> viewed here: http://pastebin.com/EuW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:5358
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-newbie/unsubscribe.cfm