House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home / Groups / Fusebox-Community

formurl2attributes question

Author:
Branden deBuhr
01/23/2008 01:57 PM

I'm using fusebox 1 in a application I wrote several years ago.  I'm now trying to do a multi image submission into my application which puts the image fieldnames as userfile[0] , userfile[1] etc...  There can be as many as 1000 images uploaded in a single array.  But the problem I'm having is the formurl2attributes.cfm file is bombing out the array before I can even get to the processing page to input the images into my server.  So, below I'm going to put the code to process the upload and first the formurl2attributes code which is having the problem.   I'm thinking that essentially, based on what I've read and seen in that file that it is trying to rename the userfile fieldnames to something else or that it's not doing that because the fieldnames don't have the fuseaction_ prefix attached to them.  So I need to either attach that to the fieldnames before the line 80 of formurl2attributes or find another way to process this information. Code from the form... <table> <cfform action="/index.cfm?action=uploadmultiphotos&id=#attributes.id#" method="POST" enctype="multipart/form-data"> <tr>     <td><input type="File" name="userfile" id="[0]" size="30"></td> </tr> <tr>     <td><input type="File" name="userfile" id="[1]" size="30"></td> </tr> <tr>     <td><input type="File" name="userfile" id="[2]" size="30"></td> </tr> <tr>     <td><input type="File" name="userfile" id="[3]" size="30"></td> </tr> <tr>     <td><input type="Submit" value="Upload Files"></td> </tr> </cfform> </table> The code which is getting the error... <!--- This is for converting form fields to attributes scoped variables ---> <cfif isdefined("form.fieldnames")>     <cfloop list="#form.fieldnames#" index="field">         <CFIF refindnocase("[[:alpha:]]",left(trim(field),1)) and NOT ISDEFINED( 'Caller.ATTRIBUTES.' & trim(field) )>             <cfset "caller.attributes.#trim(field)#" = "#evaluate("form.#trim(field)#")#">             <!--- This is so that you can have multiple type="image" buttons on the same page, if                 you name the button name="fuseaction_[the value you want]" it will set the fuseaction                 to that value--->             <cfif findnocase("fuseaction_",field) and findnocase(".x",field)>                 <cfset setfuseaction=replacenocase(field,"fuseaction_","")>                 <cfset setfuseaction=replacenocase(setfuseaction,".x","")>                 <cfif refind("[0-9]",setfuseaction)>                     <!--- This is so you can associate an "ID" with an image button (optional) like this:                         <INPUT type="Image" src="/IMAGES/MYIMAGE.GIF" NAME="fuseaction_addthisaddress56">                         it would return ID=56 That way you can a bunch of image buttons in the same form                         that do the same thing but each one has an ID associated with it.                         --->                     <cfset thisid=val(mid(setfuseaction,refind("[0-9]",setfuseaction),len(setfuseaction)))>                     <cfif thisid>                         <cfset caller.ID=thisid>                     </cfif>                 </cfif>                            </cfif>             <!--- Remove these next 2 lines if you don't want a list of all attributes...             it'll speed up processing by about .15 millisecond--->             <cfset request.attributeslist = listappend(request.attributeslist,trim(field),"&")>             <cfset request.attributeslist = listappend(request.attributeslist,urlencodedformat(evaluate("form.#trim(field)#")),"=")>         </cfif>     </cfloop> </cfif> Here is the code which is supposed to process the form input. <cfset variables.filelist = ""> <cfset variables.nameconflict = "makeunique"> <cfset variables.destination = "c:\www\gallery"> <!------------------ LOOP OVER FORM.USERFILE[NO] - Break when it's finished ------------------------> <cfloop from="0" to="10000" index="i">     <cftry>         <cffile action="upload" filefield="#attributes["userfile[i]"]#" destination="#variables.destination#" nameconflict="#variables.nameconflict#">     <!--- <cfquery datasource="#request.maindsn#">     insert into photos     </cfquery> --->         <cfset variables.filelist = variables.filelist&",#cffile.serverfile#">     <cfcatch><cfbreak></cfcatch>     </cftry> </cfloop> <cfloop list="#variables.filelist#" index="i">     <cfoutput>Image <b>#i#</b> has been uploaded.<br></cfoutput> </cfloop> -- Founder - Hot Media Group, Inc., Email:  Branden@HotMediaGroup.com Office: 630-724-0467 Ext. 51 Mobile: 630-215-9788 AOL IM: BrandendeBuhr Google Talk: Branden.deBuhr Text: 6302159788@TMoMail.net


Search fusebox-community

February 12, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29