coldfusion cffile and cffile.serverFile

bugwood
bugwood used Ask the Experts™
on
Good morning everyone,

Please, i have a problem that i'm trying to save the filename after uploading it. In the first upload, my program saves the file's name correctly. As of the second try, it saves the path of the temporary file on the server like: C:\ColdFusion9\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp8239291811410939198.tmp. My code is attached.

Please i would like to know how to solve it if anyone can help. Thank you

<cfif IsDefined("Client.AUT_ID") and IsDefined("Client.isLoggedIn")>
<!--- Check to see if the Form variable exists. --->

<cfif '#form.filename#' NEQ '' >

   <!--- If TRUE, upload the file. --->
   
   <cffile action = "upload" 
      fileField = "form.filename" 
      destination = "D:\webroot\beta\striketeam\" 
      accept = "application/pdf, image/jpeg, image/jpg, image/gif" 
      nameConflict = "MakeUnique">
      


       <cfif '#form.flagdescription#' NEQ ''>

	          <cfset flags=#form.flags#&','&#form.flagdescription#>
    
                  <CFQUERY NAME="orderquery" DATASOURCE="kpimage">  
     
                   INSERT INTO TBL_JobOrder
                    (sitename, location, latitude, longitude, email, phone, jobtype, jobdescription, arealocation, size, method, date, flags, natureland, other, filename, species)   
                      VALUES ('#form.sitename#', '#form.location#', '#form.latitude#', '#form.longitude#', '#form.email#', '#form.phone#', '#form.jobtype#', '#form.jobdescription#', '#form.arealocation#', '#form.size#', '#form.method#', '#form.date#',     '#flags#', '#form.natureland#', '#form.other#', '#cffile.serverFile#', '#species#')  
       
                </CFQUERY>
    
      <cfelseif '#form.flagdescription#' EQ ''>

                <CFQUERY NAME="orderquery" DATASOURCE="kpimage">  
     
                  INSERT INTO TBL_JobOrder
                  (sitename, location, latitude, longitude, email, phone, jobtype, jobdescription, arealocation, size, method, date, flags,natureland, other, filename, species)   
                   VALUES ('#form.sitename#', '#form.location#', '#form.latitude#', '#form.longitude#', '#form.email#', '#form.phone#', '#form.jobtype#','#form.jobdescription#', '#form.arealocation#', '#form.size#', '#form.method#', '#form.date#', '#form.flags#', '#form.natureland#', '#form.other#', '#form.filename#', '#species#')        
               </CFQUERY>
      </cfif>  
 <cfelse>
 
  <cfif '#form.flagdescription#' NEQ ''>

	          <cfset flags=#form.flags#&','&#form.flagdescription#>
              
   <CFQUERY NAME="orderquery" DATASOURCE="kpimage">  
     
                   INSERT INTO TBL_JobOrder
                    (sitename, location, latitude, longitude, email, phone, jobtype, jobdescription, arealocation, size, method, date, flags,natureland, other, species)   
                      VALUES ('#form.sitename#', '#form.location#', '#form.latitude#', '#form.longitude#', '#form.email#', '#form.phone#', '#form.jobtype#', '#form.jobdescription#', '#form.arealocation#', '#form.size#', '#form.method#', '#form.date#',     '#flags#', '#form.natureland#', '#form.other#', '#species#')  
       
                </CFQUERY>           
              
  <cfelseif '#form.flagdescription#' EQ ''>            
 <CFQUERY NAME="orderquery" DATASOURCE="kpimage">  
     
       INSERT INTO TBL_JobOrder
          (sitename,location, latitude, longitude, email, phone, jobtype, jobdescription, arealocation, size, method, date, flags, natureland, other, species)   
       VALUES ('#form.sitename#','#form.location#','#form.latitude#', '#form.longitude#', '#form.email#', '#form.phone#', '#form.jobtype#', '#form.jobdescription#', '#form.arealocation#', '#form.size#', '#form.method#', '#form.date#', '#form.flags#', '#form.natureland#', '#form.other#', '#species#')  
       
    </CFQUERY>
 </cfif>
</cfif>
<cflocation url="thankyou.cfm" addtoken="no">
<cfelse>
  <p align="center"> You Must log in before</p>
  <cfinclude template="index.cfm" >
</cfif>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015
Commented:
That's because you're using the wrong variable in the second query.  It should be #cffile.serverFile# instead of #form.filename#

<CFQUERY NAME="orderquery" DATASOURCE="kpimage">  
INSERT INTO TBL_JobOrder .....
VALUES (...., '#form.filename#',  ......)        <!---- wrong variable name ---->
</CFQUERY>

Also, it looks like you really don't need to repeat the query multiple times.  Just use a single cfquery and place the cfif/cfelse logic inside the sql.


Author

Commented:
Thank you very much

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial