4 Replies Latest reply on Mar 4, 2008 1:56 AM by Adventsparky


      Hi there,

      basically I am setting up a file management system through coldfusion and everything works perfect except one minor detail, as always ;)

      In the section where I upload the file I use expandPath("../images/userimgs") and later on after I rename the file I put the route to the file in a text field in a database.

      Everything so far works fine, the problem is, in the text field, the expression has no forward slashes in it, the route to the file is just a line of directory names. Currently he site is local, Would that affect it in any way?
        • 1. Re: expandPath
          Level 7
          post your code that inserts the directory. there's likely a problem with

          do you use the #cffile.serverDirectory# var or insert the path manually?

          Azadi Saryev
          • 2. Re: expandPath
            Adventsparky Level 1
            <cfif structKeyExists(form, "prof_img")>

            <cfset destination = expandPath("../images/userimgs")>

            <cffile action="upload" destination="#destination#" filefield="FORM.prof_img" nameconflict="makeunique" >

            <cfset img1= UserID& DateFormat(Now(),"DDMMYY") & TimeFormat(Now(),"HHmmss")>

            <cfset img =ListAppend(img1,FILE.ServerFileExt,".")>

            <cffile action="rename" source="#destination#/#cffile.ServerFile#" destination="#destination#/#img#" >
            <cfset fileloc=#destination# & "/" & #img#>

            <cfquery datasource="foliobox">
            UPDATE site_user SET prof_img='#fileloc#'
            WHERE userid=<cfqueryparam value="#FORM.userid#" cfsqltype="cf_sql_numeric">


            Now I just tested this and checked the db, here is my entry into it:


            See no '/' except fo the one I put in while setting the fileloc variable
            • 3. Re: expandPath
              Level 7
              see if using cfqueryparam makes a difference:
              UPDATE site_user SET prof_img=<cfqueryparam cfsqltype="cf_sql_varchar"

              if not, try setting your fileloc var as a string:
              <cfset fileloc="#destination#/#img#">

              Azadi Saryev
              • 4. Re: expandPath
                Adventsparky Level 1
                Thanks a lot. the cfqueryparam worked a treat. Now the filename is perfect. Still can't get the image to display though ;) but the path is fine.