First, check for file existence before the transaction for each
iteration of the loop.
On the isPrimary issue, if the first image is always the primary
image, then you don't need a form element for it, right? So, either
set a variable to 1 or 0 depending on which iteration of the loop
you're on, and use that value on your insert statement, or use an
expression like #iif("i is 1","1","0")#
Cheers,
Kris
> <!--- Accept the file upload --->
> <cfloop from="1" to="3" index="i">
>
>
> <cffile
> action="upload"
> filefield="file#i#"
> result="cffile.file#i#"
> destination="#ExpandPath('users/uploads/')#"
> nameconflict="makeunique"
> accept="image/jpg, image/JPG, image/jpeg, image/JPEG, image/gif, image/GIF,
> image/pjpeg, image/pjpg">
[snip]
> <!--- Upload to database --->
> <cfquery datasource="wioDB">
> INSERT INTO Images (ProdID, Image, IsPrimary)
> VALUES (#Product.ProdID#,'#cffile['file'&i].serverFile# ',
> '#FORM.IsPrimary#')
> </cfquery>
>
> </cfloop>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 by AdobeĀ®
Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7.
Free Trial. http://www.adobe.com/products/coldfusion
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:271131
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4