Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

What is correct notation for complex variables

Guest
Jun 12, 2011 Jun 12, 2011

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

651
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 13, 2011 Jun 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#') >

...
Translate
LEGEND ,
Jun 12, 2011 Jun 12, 2011

Array notation is your friend.

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 13, 2011 Jun 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 13, 2011 Jun 13, 2011
LATEST

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" />

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources