Paul, You have uploadImage() set to return a string, not to place the "newImageName" variable in the variables scope. A couple of suggestion, depending on which way you want to go:
1) If you want to return the string back to the function that calls the uploadImage() simply do <cfset newImageName = imageHandler.uploadImage(form)/> and your "newImageName" variable will be available. You should also var scope that variable in both functions. 2) If you want to place the "newImageName" variable into the variables scope of the imageHandler, you should set the returntype of uploadImage() to void and do a <cfset variables.newImageName = file.serverFile /> HTH, Jon On Mar 7, 2007, at 11:10 AM, Paul Giesenhagen wrote: > I have a situation I am completely baffled with . below is code > from the > "action" page and the method pulled out of a CFC. > > > > I can't seem to get it to return the "newImageName" variable . when > I output > it after the upload it errors out (I have outputted the variable > inside of > the method and it outputs the image name just fine. Is there > something I am > doing wrong and not seeing here? > > > > Thanks in advance!! > > > > <!--- Initialize the object ---> > > <cfset imageHandler = createObject("component", > "giesenhagen.components.imageHandler") /> > > > > <!--- Pass in the form collection to "upload" the image ---> > > <cfset imageHandler.uploadImage(form) /> > > > > <cfoutput>#newImageName#</cfoutput> <!--- THIS produces an error that > newImageName is not found in variables ---> > > > > > > > > <!--- Here is the uploadImage method from the CFC ---> > > <cffunction name="uploadImage" output="false" returnType="string" > hint="Uploads Image to Directory"> > > > > <cffile accept="*" action="upload" > destination="#Application.sitePath#temp#Application.delimiter#" > filefield="image" nameconflict="makeunique"> > > > > <cfset newImageName = file.serverFile /> > > <cfreturn newImageName /> > > </cffunction> > > > > > > Paul Giesenhagen > > QuillDesign > > http://www.quilldesign.com > > 417-885-1375 > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion MX7 and Flex 2 Build sales & marketing dashboard RIAâs for your business. Upgrade now http://www.adobe.com/products/coldfusion/flex2 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:271885 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4