> Also using cftry and cfcatch is not enough, if the use upload an empty file the cfcatch will not catch it, but the CFFILE.ServerFile is not created, when you try to reference it you will get an error. (This was caught by our QA guy!).
I've never been able to get CF 4.5 or 5 to upload a 0 byte file. cffile errors out and my cfcatch ...well... it catches it guess if you were getting them you could use cffile action="read" to and the contents of the form field itself to get the file info Allowing users to upload files has always been a tedious one but yes cftry is enough... you just dont stop with the cftry wrapped around the cffile tag... the next block would be something to make sure the accept attribute didn't let the wrong type through by checking the ServerFileExt against whatever it is you wanted to upload wrapped in a cftry of course...this time cfcatch will delete the uploaded file and set a message to inform the user somehow. ( and any cfcatch's after this point) normally the sequence would be something like this for me Upload to temp... Re Check Type Check For same named files (if neccassarry) Rename (if neccassary) Move (if neccassary) Enter data to database each step is wrapped in its own error catching block most catches look like this <cftry> do something.... <cfcatch type="any"> <cfset errmsg = "There was a problem doing something."> <cffile action="delete" file="blahblah <cflocation url="index.cfm?errmsg=#errmsg#" addtoken="no"> </cfcatch> </cftry> ----- Original Message ----- From: "Lee, Sima - Workstream" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Thursday, May 29, 2003 6:58 AM Subject: RE: CFFILE Upload question > Hi, > > What I did is do both client and server side validations. > > The client side check is put all the accepted file extension in a list then use a JavaScript to validate the file field at the submission. If the user uploaded an unaccepted file display alert message do not submit the form. > > The server side validation I did more than just use the attributes in the CFFile tag. After the uploading I actually check the extension of the server file again because some MIME type let go not only one type of the file. If the uploaded file is unacceptable I will deleted it straight away. > > Also using cftry and cfcatch is not enough, if the use upload an empty file the cfcatch will not catch it, but the CFFILE.ServerFile is not created, when you try to reference it you will get an error. (This was caught by our QA guy!). > > If you need some JavaScript for this please let me know I will send you directly. > > Hope this helps. > > > Sima > > > -----Original Message----- > From: Scott Wolf [mailto:[EMAIL PROTECTED] > Sent: Wednesday, May 28, 2003 6:01 PM > To: CF-Talk > Subject: Re: CFFILE Upload question > > > Actually.....let me be more specific. > > I tried it and it gives a CF error message. What can I do to avoid that? I > just want to redirect the user back to the upload form and have a message > display at the top saying something like "Uploading this file type is not > allowed. You may only upload images and audio clips." > > That's where I really need the help. > > (or was that response supposed to be some sort of CFTRY pun? :P ) > > Scott > ----- Original Message ----- > From: "Bryan Love" <[EMAIL PROTECTED]> > To: "CF-Talk" <[EMAIL PROTECTED]> > Sent: Wednesday, May 28, 2003 5:36 PM > Subject: RE: CFFILE Upload question > > > > try it and see :) > > > > +-----------------------------------------------+ > > Bryan Love > > Database Analyst > > Macromedia Certified Professional > > Internet Application Developer > > TeleCommunication Systems > > [EMAIL PROTECTED] > > +-----------------------------------------------+ > > > > "...'If there must be trouble, let it be in my day, that my child may have > > peace'..." > > - Thomas Paine, The American Crisis > > > > "Let's Roll" > > - Todd Beamer, Flight 93 > > > > > > > > -----Original Message----- > > From: Scott Wolf [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, May 28, 2003 2:14 PM > > To: CF-Talk > > Subject: CFFILE Upload question > > > > > > If I specify MIME types in the ACCEPT attribute such as: > > > > <CFFILE ACTION="UPLOAD" FILEFIELD="Form.Upload1" > > DESTINATION="C:\Inetpub\wwwroot\imghost\#SecureCheck.txtUserName#" > > NAMECONFLICT="MAKEUNIQUE" ACCEPT="text/html"> > > > > What happens if someone tries to upload a file that isn't on the "accept" > > list (like a jpg)? Does a CF error page display? I'm new to working with > > CFFILE and I'm not even sure if I'm asking the right question. Any help > > would be greatly appreciated. Thanks! > > > > Scott Wolf > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

