Skip to main content
August 5, 2010
Question

uploading files using the server path for the destination

  • August 5, 2010
  • 1 reply
  • 1194 views

I'm currently trying to upload a file using the cffile tag and the file only gets uploaded to my site's directory destination if I use the computer's directory path versus the server path. Anyone know why?

It only works with #dest1# as the destination, not #dest2#

<cfset dest1="C:\ColdFusion9\wwwroot\practice\uploads" />

<cfset dest2="http://localhost:8500/practice/uploads/" />

<cffile action="upload" destination="#dest2#" filefield="form.myImage" />

My error is:

Attribute validation error for tag CFFILE.

The value of the attribute destination, which is currently http://localhost:8500/practice/uploads/, is invalid.
The error occurred in C:\ColdFusion9\wwwroot\practice\move_file.cfm: line 4
2 : <cfset dest2="http://localhost:8500/practice/uploads/" />
3 : 
4 : <cffile action="upload" destination="#dest2#" filefield="form.myImage" />

    This topic has been closed for replies.

    1 reply

    Inspiring
    August 5, 2010

    >> Anyone know why?

    CFFILE manipulates files on the local file system. So "destination" refers to a physical path on the server, not a url as you have in #dest2#.

    August 5, 2010

    still not quite sure what you mean. what do you mean by 'physical path on the server'? Isn't dest2 a 'physical path' on the local server? If my site were http://www.mysite.com and images were stored in a folder called 'uploads' off the root, what would the 'physical path' be?

    Inspiring
    August 5, 2010

    The physical path is the variable that worked in your opening post.  If your long term plan is get someone else to host your site, you'll either have to get them to tell you the path, or use relative addressing instead of absolute.

    To complicate things further, if your site gets hosted on a linux/unix box, you'll have to use forward slashes instead of backslashes.