Would someone take a look at this code and tell me why I get the error:

 

"missing ) in parenthetical"

<font face=arial></font>\n

(That error code would seem to be from a CF error message, but with the

code below, I can't view it in Firebug.)

 

when I run this code?  (It's from Ben Nadel's blog about uploading

files with ColdFusion and jQuery AJAX. has anyone successfully

run this code on CF 8 as it is?  Is it out-of-date for CF 8?)

 

I've got jQuery AJAX working on my forms with no problem, but I just

can't seem to get the file uploading to work within an AJAX form.

 

Any suggestions would be most appreciated!

 

Rick

 

----------------------------------------------------------------------------
----------------------------------------------

form.cfm

----------------------------------------------------------------------------
----------------------------------------------

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<html>

<head>

     <title>ColdFusion And AJAX File Upload Demo</title>

     <script type="text/javascript" src="jquery-1.2.6.min.js"></script>

     <script type="text/javascript" src="ajax_upload.js"></script>

</head>

 

<body>

 

     <form>

 

          <h1>ColdFusion And AJAX File Upload Demo</h1>

 

          <input type="file" name="upload1" size="60" /><br /><br />

          <input type="file" name="upload2" size="60" /><br /><br />

          <input type="submit" value="Upload Files" />

 

      </form>

 

</body>

</html>

 

----------------------------------------------------------------------------
----------------------------------------------

ajax_upload.js

----------------------------------------------------------------------------
----------------------------------------------

$(

     function(){

 

          var jForm = $( "form:first" );

                    

          jForm.submit(

 

               function( objEvent ){

                                                                

                    var jThis = $( this );

                    var strName = ("uploader" + (new Date()).getTime());

                    var jFrame = $( "<iframe name=\"" + strName + "\"
src=\"about:blank\" />" );

 

                    jFrame.css( "display", "none" );

                    jFrame.load(

                                                                

                         function( objEvent ){

 


                              var objUploadBody = window.frames[ strName
].document.getElementsByTagName( "body" )[ 0 ];

                              var jBody = $( objUploadBody );

                              var objData = eval( "(" + jBody.html() + ")"
);

                              prompt( "Return Data:", objData );

 


                                   setTimeout(

                                        function(){

                                             jFrame.remove();

                                        },

                                        100

                                   );

     }

);

 

$( "body:first" ).append( jFrame );

 

     jThis

                  .attr( "action", "cf_file_handler.cfm" )

                  .attr( "method", "post" )

                  .attr( "enctype", "multipart/form-data" )

                  .attr( "encoding", "multipart/form-data" )

                  .attr( "target", strName );

                }

     );

}

);

 

 

----------------------------------------------------------------------------
----------------------------------------------

upload_act.cfm

----------------------------------------------------------------------------
----------------------------------------------

 

<cfset arrFiles = [] />

 

<cfloop index="strFileIndex" from="1" to="10" step="1">

 

     <cfset strField = "upload#strFileIndex#" />

 

 

          <cfif ( StructKeyExists( FORM, strField ) AND Len( FORM[ strField
] ) )>

 

                <cffile action="upload" filefield="#strField#"
destination="#ExpandPath( './files/' )#"

                              nameconflict="makeunique"/>

 

                <cfset ArrayAppend( arrFiles, CFFILE.ServerFile ) />

 

         </cfif>

 

 

</cfloop>

 

 

<cfsavecontent variable="strHTML">

 

     <cfoutput>

 

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

               <html>

               <head></head>

               <body>#SerializeJSON( arrFiles )#</body>

               </html>

 

     </cfoutput>

 

</cfsavecontent>

 

 

<cfset binResponse = ToBinary( ToBase64( strHTML ) ) />

 

<cfheader name="content-length" value="#ArrayLen( binResponse )#" />

 

<cfcontent type="text/html" variable="#binResponse#"/>

 

 

----------------------------------------------------------------------------
----------------------------------------------

"My reading of history convinces me that most bad government results from
too much government."

  - Thomas Jefferson

 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:319912
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to