I would very much like to use the multi-file uploader on a site I’m working on but I need to also insert a record to the application database connecting the uploaded file with the property it belongs to. Unfortunately I’m struggling to find information that will help me get the page working the way I want it to. I want to use cfselect to allow the admin staff to choose the property’s name from the drop-down list and pass on the property name to the action page along with the uploaded files. The problem is that an error is generated because the action file needs to compare the as yet unsubmitted property name with the database property names. Can you suggest how I might go about getting this to work? Here’s the code:
Form
<cfquery name=“propertylist” datasource=“*****”>
SELECT propertyname
FROM properties
</cfquery>
<cfform action=“cffileupload_action.cfm”>
<!— Choose Property to Upload Photos for —>
<div id=“chooseproperty”>
<fieldset id=“chooseproperty”>
<legend><span>Choose Property</span></legend>
<cfselect name=“propertyname” query=“propertylist” display=“propertyname” queryposition=“below”></cfselect><br />
</fieldset>
</div>
</cfform>
<!— Choose Photos to Upload —>
<div id=“photoupload”>
<fieldset id=“photoupload”>
<legend><span>Upload Photos</span></legend>
<cffileupload url=“cffileupload_action_orig.cfm?#urlEncodedFormat(session.urltoken)#&propertyname=#url.propertyname#” extensionfilter=“.jpg, .png, .jpeg” maxuploadsize=“1” title=“Photo Uploader” width=“600” addbuttonlabel=“Select Photos” clearbuttonlabel=“Remove All Photos” deletebuttonlabel=“Remove Photo” />
<input type=“submit” value=“Submit” id=“controls”>
</fieldset>
</div>
Action Page
<cffile action=“uploadall” destination=“/Applications/MAMP/htdocs/*******/properties/#Form.propertyname#/images” nameConflict=“Overwrite”>
<cfquery name=“lookupID” datasource=“*****”>
SELECT propID
FROM properties
WHERE propertyname = “#Form.propertyname#”
</cfquery>
<cfquery name=“addfilename” dataSource=“*****”>
INSERT INTO images(imagefilename, propID)
VALUES(‘#CFFILE.SERVERFILE#’, ‘<cfoutput query=“lookupID”>#propID#</cfoutput>’)
</cfquery>
I’m hoping someone may know how this could be done?