This content has been marked as final. Show 7 replies
how do i now use a cfif tag to redirect the user if he tries to upload a jpeg etc,
> ok thanks,
> how do i now use a cfif tag to redirect the user if he tries to upload a jpeg etc,
if you want to do it in CF, then you will have to use <cftry>/<cfcatch>
structure to catch the error cffile will trow when a user tries to
submit a wrong mime type file. i don't quiet remember which exception is
thrown (i think it is application) - will look it up at work and post
i found this code, do this help
Error Handling File Manipulations
Now, as I discussed in my error handling article, file manipulations can be sketchy creatures. Sometimes they don't work as we intend them to. They can also be very, very dangerous. So, I recommend wrapping each and every file manipulation in it's own try/catch block. (Don't package two of them in the same block, it will be much more difficult to trace, believe me. It's worth the little extra bit of effort.)
<cffile action="read" file="#newDir#test1.txt" variable="myVar">
<!--- genius bit of error logging here --->
yes, that's exactly what you should use. i have checked and the wrong
mime type throws exception of application type, so:
<cffile action="upload" destination="somefolder"
your wrong file type handling code goes here. depends on how you want to
handle it: show an error message on the same page and cancel form
submitting or redirect to some error page or whaever you want to do.
that works ok, accept, i get the error when i actually upload a .csv file?
i created a csv file from micosoft excel, and it will not allow it to be uploaded any ideas why?
if it was created from excel, then maybe it has excel mime type even
though it is a csv file... try using in your <cffile>:
or maybe accept="text/csv,application/csv" will work too...
these are mime type associated with csv files:
all of them should work. since csv files can be created with various
applications, exact mime tupe of a csv file will probably depend on the
application it was created with... i am just guessing here, though...
hope this helps