I guess my main problem is that first I should try to limit the number of
arguments I am sending to the function. If they are empty fields, not send.
Then when it gets to the function, determine if the variable has a file. The
problem is with the loop. I am not getting how to evaluate each argument by
number to determine if it is not blank.

Obviously, I have to set some kind of variable at the start of the loop? But
when I do that, <cfset photo = "photo" & #i# />. Does that define and set a
value to the variable?

Here is the form

<cfoutput>
<cfparam name="classphotoaction" default="" />
<cfparam name="adid" default="testing" />

<cfif classphotoaction eq "create">
<cfinvoke component="/renocfc/classifiedsphoto"
method="createclassifiedsphotos">
<cfinvokeargument name="adid" value="#adid#" />
<cfloop index="i" from="1" to="4">
<cfset photo = "photo" & #i# />
<cfinvokeargument name="#photo#" value="#photo#" />
</cfloop>
</cfinvoke>
</cfif>

<form action="#cgi.script_name#" method="post"
enctype="multipart/form-data">
<cfloop index="i" from="1" to="4">
<label for="photo#i#">Photo #i#:</label>
<input id="photo#i#" name="photo#i#" type="file" /><br />
</cfloop>
<input id="submit" name="submit" type="submit" value="Add Photo(s)
&gt;&gt;&gt;" />
<input id="classphotoaction" name="classphotoaction" type="hidden"
value="create" />
</form>
</cfoutput>

Here is the function.

<cffunction name="createclassifiedsphotos" access="public"
returntype="void">
<cfargument name="adid" type="any" required="yes" />
<cfset var createclassifiedsphotos = "" />
<cfloop index="i" from="1" to="4">
<cffile action="upload" filefield="#photofile#"
destination="\classifieds\classifiedsphotos" nameconflict="makeunique" />
<cfset photo = "#file.clientfile#" />
<cfset resize = imagenew("\classifieds\classifiedsphotos\#photo#") />
<cfset imageresize(resize,"250","") />
<cfimage source="#resize#" action="write"
destination="\classifieds\classifiedsphotos\#photo#" overwrite="yes">
<cfquery name="createclassifiedsphoto" datasource="rsoclassifieds">
insert into
classifieds_photos (
photofile,
adid
)
values (
'#photo#',
'#arguments.adid#'
);
</cfquery>
</cfloop>
<cfreturn />
</cffunction>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade to ColdFusion 8 and integrate with Adobe Flex
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3111
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to