Skip to main content
June 12, 2011
Answered

What is correct notation for complex variables

  • June 12, 2011
  • 2 replies
  • 704 views

I need to manipulate files after upload. They are all uploaded in 1 directory by a flash component and then i need to rename them and move them to the directory that corresponds with choosen categories and subcategories. Now I am having problems with finding out how to get my variables correctly

It is about the variable thisFiletoMove1, it should correspond with the destination file in the cffile tag

<cfif FileExists('#request.site.imgupload#\max_#MultiPowUploadFileName_0#')>
  <cffile action="rename"
    source="#request.site.imgupload#\max_#MultiPowUploadFileName_0#"
    destination="#request.site.imgupload#\#request.currentimgid#_max.jpg">
    <cfset thisFiletoMove1 = #request.currentimgid#_max.jpg />
</cfif>

<cfset thisFiletoMove1 = #request.currentimgid#_max.jpg /> is giving an error Invalid CFML construct found, ColdFusion was looking at the following text:

_max.jpg

Then I try

<cfset thisFiletoMove1 = #request.currentimgid & "_max.jpg" /> and I get

The source C:\websites\beta.antiek.net\demo\galleries\test\thisFiletoMove1 specified in the cffile tag is invalid

So now I am wondering, what is the correct way to do this??

Bianca

    This topic has been closed for replies.
    Correct answer BKBK

    bianca_homedev wrote:

    I need to manipulate files after upload. They are all uploaded in 1 directory by a flash component and then i need to rename them and move them to the directory that corresponds with choosen categories and subcategories. Now I am having problems with finding out how to get my variables correctly

    It is about the variable thisFiletoMove1, it should correspond with the destination file in the cffile tag

    <cfif FileExists('#request.site.imgupload#\max_#MultiPowUploadFileName_0#') >
      <cffile action="rename"
        source="#request.site.imgupload#\max_#MultiPowUploadFileName_0#"
        destination="#request.site.imgupload#\#request.currentimgid#_max.jpg" >
        <cfset thisFiletoMove1 = #request.currentimgid#_max.jpg />
    </cfif>

    <cfset thisFiletoMove1 = #request.currentimgid#_max.jpg /> is giving an error Invalid CFML construct found, ColdFusion was looking at the following text:

    _max.jpg

    Then I try

    <cfset thisFiletoMove1 = #request.currentimgid & "_max.jpg" /> and I get

    The source C:\websites\beta.antiek.net\demo\galleries\test\thisFiletoMove1 specified in the cffile tag is invalid

    So now I am wondering, what is the correct way to do this??

    These are both wrong:

    <cfset thisFiletoMove1 = #request.currentimgid#_max.jpg />
    <cfset thisFiletoMove1 = #request.currentimgid & "_max.jpg" />

    You were almost there. What you intended saying was probably

    <cfset thisFiletoMove1 = "#request.currentimgid#_max.jpg" />

    <cfset thisFiletoMove1 = #request.currentimgid# & "_max.jpg" />

    However, even better are
    <cfset thisFiletoMove1 = request.currentimgid & "_max.jpg" />
    <cfset thisFiletoMove1 = request[currentimgid] & "_max.jpg" />

    2 replies

    BKBK
    Community Expert
    BKBKCommunity ExpertCorrect answer
    Community Expert
    June 13, 2011

    bianca_homedev wrote:

    I need to manipulate files after upload. They are all uploaded in 1 directory by a flash component and then i need to rename them and move them to the directory that corresponds with choosen categories and subcategories. Now I am having problems with finding out how to get my variables correctly

    It is about the variable thisFiletoMove1, it should correspond with the destination file in the cffile tag

    <cfif FileExists('#request.site.imgupload#\max_#MultiPowUploadFileName_0#') >
      <cffile action="rename"
        source="#request.site.imgupload#\max_#MultiPowUploadFileName_0#"
        destination="#request.site.imgupload#\#request.currentimgid#_max.jpg" >
        <cfset thisFiletoMove1 = #request.currentimgid#_max.jpg />
    </cfif>

    <cfset thisFiletoMove1 = #request.currentimgid#_max.jpg /> is giving an error Invalid CFML construct found, ColdFusion was looking at the following text:

    _max.jpg

    Then I try

    <cfset thisFiletoMove1 = #request.currentimgid & "_max.jpg" /> and I get

    The source C:\websites\beta.antiek.net\demo\galleries\test\thisFiletoMove1 specified in the cffile tag is invalid

    So now I am wondering, what is the correct way to do this??

    These are both wrong:

    <cfset thisFiletoMove1 = #request.currentimgid#_max.jpg />
    <cfset thisFiletoMove1 = #request.currentimgid & "_max.jpg" />

    You were almost there. What you intended saying was probably

    <cfset thisFiletoMove1 = "#request.currentimgid#_max.jpg" />

    <cfset thisFiletoMove1 = #request.currentimgid# & "_max.jpg" />

    However, even better are
    <cfset thisFiletoMove1 = request.currentimgid & "_max.jpg" />
    <cfset thisFiletoMove1 = request[currentimgid] & "_max.jpg" />

    Inspiring
    June 12, 2011

    Array notation is your friend.

    ThisFileToMove = request[currentimgid & "_max.jpg"]

    BKBK
    Community Expert
    Community Expert
    June 13, 2011

    Dan Bracuk wrote:

    Array notation is your friend.

    ThisFileToMove = request[currentimgid & "_max.jpg"]

    Right in spirit of course. The request variable is apparently currentimgid, and so this should have read

    ThisFileToMove = request[currentimgid] & "_img.jpg"

    However, I think Bianca's problem occurs else where.