Put CFLOCATION Here 2. Use Javascript to check the extension first. In your form use this.. BLX Webmaster [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => <1133233359.980739.138670@o13g2000cwo.googlegroups.com> [ref] => [htmlstate] => on_nl2br [postusername] => webmaster@blx.net [ip] => webmaster@blx.n [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 2 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> error page - Coldfusion - Advanced Techniques

error page - Coldfusion - Advanced Techniques

hi i have a form that updates my databse with jpg file, at the min if a user uploads a different file ext, it comes up with a coldfusion error, how do i redirect this to my own error page? <CFFILE ACTION="UPLOAD" DESTINATION="c:\inetpub\wwwroot\CompanyImages\" FILEFIELD="WebSite_CompanyLogo" ACCEPT="image/pjpeg, image/jpeg, image/jpg, image/jpe_, image/pjpeg" nameConflict = "MakeUnique"> <CFSET myFileName = #cffile.serverfile#> <cfquery datasource="DPSGuide"> UPDATE Aged_Care_Facility_Details SET WebSite_CompanyLogo = '#cffile.serverfile#' WHERE ID=#ID# </CFQUERY> <CFOUTPUT>Name of file uploaded to server: #myFileName#</CFOUTPUT>...

Sponsored Links
  1. #1

    Default error page

    hi i have a form that updates my databse with jpg file, at the min if a user
    uploads a different file ext, it comes up with a coldfusion error, how do i
    redirect this to my own error page?

    <CFFILE ACTION="UPLOAD"
    DESTINATION="c:\inetpub\wwwroot\CompanyImages\"
    FILEFIELD="WebSite_CompanyLogo"
    ACCEPT="image/pjpeg, image/jpeg, image/jpg, image/jpe_, image/pjpeg"
    nameConflict = "MakeUnique">

    <CFSET myFileName = #cffile.serverfile#>

    <cfquery datasource="DPSGuide">
    UPDATE Aged_Care_Facility_Details
    SET WebSite_CompanyLogo = '#cffile.serverfile#'
    WHERE ID=#ID#
    </CFQUERY>
    <CFOUTPUT>Name of file uploaded to server: #myFileName#</CFOUTPUT>

    Sponsored Links
    Craig77 Guest

  2. #2

    Default Re: error page

    A few ideas come to mind. Since the cffile.variables are not available
    unless the file is uploaded you will need to either be ok with just
    catching any errors, doing some error discovery or you can also use
    javascript to check the file extension before upload.

    1. Catching the error. Use the CFTRY block.
    <cftry>
    <CFFILE ACTION="UPLOAD"
    DESTINATION="c:\temp"
    FILEFIELD="WebSite_CompanyLogo"
    ACCEPT="image/pjpeg, image/jpeg, image/jpg, image/jpe_,
    image/pjpeg"
    nameConflict = "MakeUnique">
    <cfcatch type="Any">
    <!--- There Was An Error --->
    Put CFLOCATION Here
    <cfabort>
    </cfcatch>
    </cftry>

    2. Use Javascript to check the extension first.
    <script language="JavaScript1.2" type="text/javascript">
    //This function checks to ensure the file uploaded is an excel or word
    doent. All others will prompt an error.
    function checkAttachment() {
    goodEXT = false;
    d = doent.Upload; //variable to access the form on the page
    var filePath = d.UploadFileName.value; //entire path of file to upload
    //alert(filePath);
    var x = filePath.lastIndexOf("\\"); //get location of last slash in
    the filePath
    var fileName = filePath.substring(x+1); //get value of filename and
    extension
    var y = filePath.lastIndexOf("."); //get location of last period in
    file path
    var ext = filePath.substring(y+1); //get value of extension
    //alert(ext);
    if (ext == 'pjpeg') { //if extension is .pjpeg, set variable to true
    goodEXT = true;
    }
    if (ext == 'jpeg') { //if extension is .jpeg, set variable to true
    goodEXT = true;
    }
    if (ext == 'jpg') { //if extension is .jpg, set variable to true
    goodEXT = true;
    }
    if (ext == 'jpe') { //if extension is .jpe, set variable to true
    goodEXT = true;
    }
    if (ext == 'pjpeg') { //if extension is .pjpeg, set variable to true
    goodEXT = true;
    }
    if (!goodEXT) { //if it's not a word or excel doent, yell at them.
    alert("You can only upload pjpeg, jpeg, jpg,jpe, and pjpeg images")
    //if not, error and don't add file
    } else {
    doent.Upload.submit(); //Submit the form.
    }
    }
    </script>

    In your form use this..
    <input type="button" name="btnUploadFiles" value="Upload File"
    class="button" onClick="return checkAttachment()">

    BLX Webmaster

    webmaster@blx.net Guest

  3. #3

    Default Re: error page

    Hi

    If you want the consistent Error Message Page through out the site you can use
    the cferror tag. this will helps you.

    or else if you want handle only the file extension error then you could use
    the cftry/cfcatch or still you can give validations in the cffile tag by
    giving the what type of files you want to accept.

    vkunirs Guest

  4. #4

    Default Re: error page

    hi i am not familar with cferror tag where would i put this, an error page for the whole site would be good?
    Craig77 Guest

  5. #5

    Default Re: error page

    Hi

    http://www.netbenefit.com/Tags/lr2_027.htm
    vkunirs Guest

Similar Threads

  1. Error positioning master page anchor objectwith automatic page numbering in INDD CS2
    By RALScaner@adobeforums.com in forum Adobe Indesign Windows
    Replies: 3
    Last Post: May 27th, 05:30 AM
  2. Replies: 1
    Last Post: September 5th, 10:09 AM
  3. error on page?
    By Tal in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 26th, 05:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •