Link to home
Create AccountLog in
Avatar of smfmetro10
smfmetro10Flag for United States of America

asked on

How do I loop over multiple file uploads and update the database with the file.serverfile name?


I have some form fields that are dynmacially named based on a recordID from a database.

In that form  a user can add  file uploads to upload images and videos.

My problem is I can't update the database with the file.serverfile name (It puts the temp file name in there)  

Here is my code so far

Thanks for the help
<cfloop array="#ListToArray(FORM.req_part_ids)#" index="req_part_id">
	<!--- Do Project level name/description (_p#_n0) --->
	<cfset project_name = FORM["TXTPROJECTNAME_P#req_part_id#_N0"]>
	<cfset project_description = FORM["txtprojectdesc_P#req_part_id#_N0"]>
	<cfset project_workplan = FORM["fleworkplan_P#req_part_id#_N0"]>

	<cffile action="upload" variable="#project_workplan#" destination="#thisDir#" nameconflict="makeunique"source="#thisDir#" >

	<!--- Update tblCandidatePortfolioProjects --->
	<cfquery name="qudateproject" datasource="accred">
			update tblCandidatePortfolioProjects
			set project_name = <cfqueryparam value="#project_name#" cfsqltype="cf_sql_varchar">,
			    project_description = <cfqueryparam value="#project_description#" cfsqltype="cf_sql_varchar">,
				work_plan_filename = <cfqueryparam value="#project_workplan#" cfsqltype="cf_sql_varchar">	
			where	req_part_id = <cfqueryparam value="#req_part_id#" cfsqltype="cf_sql_integer">

Open in new window

Avatar of Hammo777

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of smfmetro10


Thanks for the reply.
 Changing it to "filefiled" doesn not upload the files to the correct folder and gives an error of :
The form field C:\ColdFusion9\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp811849374809318685.tmp did not contain a file. "

I think the reason is because there is  not a "hard coded" form field name being passed.

Thats the reason why I thought I could use the variable attribute for the cffile. It just doesnt put the file.serverfile name in the database.

Do you know of a way to take this part of the loop :
"<cfset project_workplan = FORM["fleworkplan_P#req_part_id#_N0"]>"
and have it output the actual name of the file?

Disregard my last comment
"FileField" was the correct attribute.

The problem was with the loop. I did'nt need the "Form" in FORM["txtprojectdesc_P#req_part_id#_N0"]>

Avatar of Hammo777

the filefield argument expects a form field NAME (not the value of the field) so I think you need:


You posted before I could. Excellent troubleshooting.