I’m using Coldfusion 8 on an Ubuntu Linux server with Apache and MySQL. Any file uploaded get stored in the Coldfusion temp directory:
[/opt/coldfusion8/runtime/servers/coldfusion/SERVER-INF/temp/wwwroot-tmp/neotmp17260.tmp] I obviously want it to be stored in to /var/www/cfm3/images [which the value of #destination#. I have tried other solutions provided by this site but they tend to fork off to other solutions that have not solved my solution. Below is the an example of my code.
<cfset destination = expandPath("images") />
<cfif not directoryExists(destination)>
<cfdirectory action="create" directory="#destination#">
</cfif>
<cfloop from="1" to="#num_users#" index="i">
<cfoutput>User #i# Photo Upload :
<cfif isDefined("#i#")>
<cffile action="upload"
fileField="#i#"
accept="image/jpeg, image/gif, image/png"
destination="#destination#"
nameConflict="makeUnique"
mode = 777>
<cfdump var="#upload#">
<p>Thank you, your file has been uploaded.</p>
</cfif>
<input type="file" name="#i#" /><br />
</cfoutput>
</cfloop>
Any help would be greatly appreciated. 😀
I have a hunch the problem lies within how you are creating the
destinationvariable, assuming it is correct (even after a create), and then immediately passing it to CFFILE.Refer to this similar question (and solution):
Saving File to Server in ColdFusion
In this question linked above, the answerer notes that:
This is very similar behavior to what you are experiencing–you want the file in a specific folder, but rather than error out, it ultimately lands in the “temp” dir.
I’d get some trace/debugging info in your template, specifically surrounding the value of the destination variable, prior to it being fed to CFFILE. Something doesn’t quite gel with your description, and it could very well be a faulty path, or perhaps permissions surrounding it.