cffile upload function if it fails I want to redirect to an error page

I am building an uploader, and I want to set a couple of parameters so the client cannot upload any type of file.

This is the cfm file which processes the upload includes/processFileSubmission.cfm:

<cfparam name="form.fileUpload" default="">
<cfparam name="form.hiddenFileInput" default="">
<cfset dirName = expandPath("../../data/images/volvelle/")>

<cfif len(trim(form.fileUpload))>
    <cfset fileName="#form.actual_name#_#form.email#" />
    <cfset fileName=Replace(fileName, " ", "-", "ALL") />
    <cfset fileName=LCase(fileName) />
    <cfset fileSize = createObject("java","java.io.File").init(form.fileUpload)>
    <cfif fileSize.length() LT 52428800>
        <cffile
            action="upload"
            result="upload"
            accept="image/*"
            fileField="fileUpload"
            nameconflict="makeunique"
            destination="#dirName#/#fileName#__#hiddenFileInput#"
        >
    </cfif>
    <cfdump var="#upload#">
    <cfif #upload.CONTENTTYPE# NEQ 'image'>
        <cfoutput>Upload file was not an image</cfoutput> // this does not get reached. 
        <!--- <cflocation url="error.cfm"> --->
    <cfelse>
        <cfoutput>Upload file was an image</cfoutput> // this does get reached for an image file
    </cfif>
</cfif>

In my html I am going to use an accept attribute to filter only for image files, but in order to test this I have currently disabled that (I still need to do a back end check).

So the html was this (index.cfm):

<input class="el-7 button" type="file" name="fileUpload" accept="image/*" />

But is now this:

<input class="el-7 button" type="file" name="fileUpload">

If I upload an image, I can see this output from <cfdump var="#upload#" />

This shows that upload.CONTENTTYPE = image, which is what I am trying to test in my condition at the bottom of the script. I am so-so with cfm but always get mixed up and variable interpolation but I have tried <cfif upload.CONTENTTYPE NEQ 'image'> which did not work either. Not sure if it needs quotes.

However if I then upload a pdf, the cffile fails, but seems to pass back to my confirm.cfm file which should return errors or a success message based on the form inputs.

This is the error:

Accept  image/*
Detail  <br>Only files of type image/* can be uploaded. <br>Verify that you are uploading a file of the appropriate type.
Message The MIME type of the uploaded file application/pdf was not accepted by the server.

This is the content of my confirm.cfm file

<cfparam name="FORM.fileUpload" default="">
<cfparam name="FORM.name" default="">
<cfparam name="FORM.actual_name" default="">
<cfparam name="FORM.email" default="">
<cfparam name="FORM.comments" default="">
<cfparam name="FORM.auth" default="">
<cfparam name="FORM.gcapthca" default="">

<cfif len(trim(form.fileUpload))>
    <cfinclude template="includes/processFileSubmission.cfm">
</cfif>

<cfif len(trim(FORM.auth)) NEQ 0 || len(trim(FORM.name)) NEQ 0>
    <cflocation url="thanks.cfm">
</cfif>

    <div class="content">
    <cfparam name="errors" default="">
        <cfif isDefined ("FORM.submit")>
            <cfif len(trim(FORM.email)) NEQ 0 AND NOT isValid("email", FORM.email)>
                <cfset errors = errors & "<li>Please enter a valid email address</li>">
            </cfif>
            <!--- clean up variables --->
            <cfset FORM.fileUpload="">
            <cfset FORM.name="">
            <cfset FORM.actual_name="">
            <cfset FORM.email="">
            <cfset FORM.comments="">
            <cfset FORM.gcapthca="">
            <cfoutput>
                <form method="post" action="#CGI.SCRIPT_NAME#" class="m-t-5">
                    <input type="hidden" name="submitted" value="true">
                    <cfif LEN(errors) GT 0><!--- checking for errors --->
                    Errors
                    <ul class="errors">
                        #errors#
                    </ul>
                    <a href="javascript:history.back(1)">Go back</a>
                    <cfelse>
                        Thank you. Your file has been submitted.<br />
                        <a href="/">slackwise</a><br />
                        e: email address
                        We never disclose email addresses to third parties.
                    </cfif>
                </form>
            </cfoutput>
        </cfif>
    </div>

All of this code works, it worked for a simple feedback form, I just need some error handling for the image uploader which is new.

TL/DR

I want to have a specific file redirect if the user tries to upload a non-image file. However in addition it might also be useful to have some generic fallback redirect page in case of any other type of error. How do I implement this?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật