We help IT Professionals succeed at work.
Get Started

How to pass a form field to a cfc on submission

Last Modified: 2013-12-24
I have a form that gets submitted to itself and then calls a cfc in order to do the needed db work.  This cfc then calls another cfc to upload an image file onto the server.   However I am continually getting a fun message from CF saying that "The form field fileLoc did not contain a file. "

I am trying to figure out why the field which does contain a .tmp file fro mupload - does not pass through to the image upload script properly.

The form submits and then the code goes like this....

thanks all
Is form updating ...
<cfif request.BusinessError EQ "" AND isDefined("form.updatebusiness")>
<cfset bus.bus_ID = business.SetBusiness(argumentcollection=form)>
<cfset msg = form.bus_Name & " Updated Successfully.">
This returns the id of the business
SetBusiness cfc looks like this...
<cfquery name="rsInsert" > Do the form field data entry</cfquery>
<!--- upload image here --->
<cfif form.bus_Logo NEQ "">
<cfset img = uploadImage(#bus_ID#,#form.bus_Logo#)></cfif>
You can see here that the file field is getting passed to yet ANOTHER CFC and uploadImage looks like this...
<cffunction name="uploadImage" hint="send me the upload file and bus ID and I will insert it.">
		<cfargument name="bus_ID" required="yes" hint="business ID you goof! numeric of course :)">
		<cfargument name="fileLoc" required="yes" hint="send me the file field.">
			<!--- Search for existing business folder --->
			<cfdirectory action="list" directory="#request.folderStruct#memberLogos" name="findFolder" filter="#bus_ID#">
				<!-- If no folder exists, create one --->
			<cfif findFolder.recordcount IS 0>
				<cflock name="crDir" timeout="30" type="exclusive">
					<cfdirectory action="create" directory="#request.folderStruct#memberLogos/#bus_ID#">
			<!--- Insert uploaded file--->
			<cflock name="crDir" timeout="30" type="exclusive">
				<cffile action="upload" filefield="fileLoc" destination="#request.folderStruct#memberLogos/#bus_ID#/" nameconflict="overwrite" accept="image/*">
<cfset fileName = cffile.clientFile>
<cfquery name="update_image">Update the business record with the 'filename'

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE