Reputation: 2627
I have an assortment of issues, but I'm going to concentrate on one here. How to I access the object created from a cffile upload. I am currently doing as so.
<cffile action="upload" destination="#Application.filePath#Pics/" filefield="image1" nameconflict="makeunique">
<cfif isDefined ("cffile.serverFile")>
<cfset image1Place = #cffile.serverFile#>
</cfif>
but that doesn't seem like it would work well with multiple file uploads, which happens to be my case.
Upvotes: 1
Views: 641
Reputation: 16945
If you're worried about the result object being blown away as a consequence of multiple invocations of cffile, then you can use the "result" attribute to distinguish them:
<cfset uploadResults = {}>
<cfloop list="#form.filelist#" index="myFile">
<cffile action="upload" destination="#Application.filePath#Pics/"
filefield="#myFile#" nameconflict="makeunique"
result='uploadResults.#myFile#'>
<cfif StructKeyExists(uploadResults, myFile)>
<cfset image1Place = uploadResults[myFile].serverFile>
</cfif>
</cfloop>
Upvotes: 3