Hi there
Wondering if anyone could assist..
I have a cfc in my model that uploads images to my server from a
form..what I am trying to do is validate that the file isnt over a
certain size and is a jpeg file....at the moment in my model cfc I
have the following code...
<cffile
action="upload"
filefield="imageArtist"
destination="/images/"
nameConflict="makeUnique">
<!---Validation--->
<!---Make Sure the file isnt more than 50K--->
<cfif cffile.FileSize GT 51250>
show error to user
<cfelseif cffile.ClientFileExt NEQ "jpg">
show error to userDo something here
<cfelse>
upload file
</cfif>
What I would like to do is move the validation from the model cfc into
my handler cfc for the upload artist image method...but am unsure of
how to achieve this
At the moment my handler looks like this
<!---Set Artist Image() Method--->
<cffunction name="setImage" returntype="void" output="false"
access="public" hint="uploads an image for the artist">
<cfargument name="EVENT" returntype="any">
<!---Reference to the request collection--->
<cfset var rc = EVENT.getCollection()>
<!---Validation--->
<!---If image field is empty--->
<cfif rc.imageArtist is "">
<cfset getPlugin("messagebox").setMessage("warning","please select
an image to upload")>
<cfelse>
<!---Logic to prepare view--->
<cfset artist = createObject
('component',"myapp.model.mdl_artistService")>
<!---Run upload artist image method--->
<cfset rc.setArtistImage = artist.setArtistImage(rc.name_art)>
</cfif>
<!---Reroute user back to artist page--->
<cfset setNextRoute("artist/#rc.name_art#")>
</cffunction>
Any assistance would be appreciated...thanks