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

A help in upload

Participant ,
Jan 27, 2009 Jan 27, 2009

Copy link to clipboard

Copied

Hi i am trying to upload 5 files in row using a loop. but it showing me an erro:

here is the code i am tryinh:


<cfloop from="1" to="5" index="idx">
<cfoutput>
<cfif form.upload#idx# IS NOT "">
<cffile action="upload" filefield="upload#idx#" destination="#request.siteURL#core/#NewUploadDir#/"
nameconflict="makeunique" accept="image/*">
<cfset resizeFile = "#cffile.ServerFile#">
<cfset imageCFC = createObject("component","core.cfc.image") />
<cfset imageCFC.resize(','#request.file_path#core\#NewUploadDir#\#resizefile#','#request.file_path#core\#NewUploadDir#\rr_#resizefile#',150,150) />
<cfif fileexists('#request.file_path#core\#NewUploadDir#\#resizefile#')>
<cffile action="delete" file="#request.file_path#core\#NewUploadDir#\#resizefile#">
</cfif>
<cfset form.file#idx# = "rr_#resizefile#">
<cfelse>
<cfset form.file#idx# = "">
</cfif>
</cfoutput>
</cfloop>


it is showing me this error:

Invalid CFML construct found on line 12 at column 28.
ColdFusion was looking at the following text:

#

The CFML compiler was processing:
A cfif tag beginning on line 12, column 12.
A cfif tag beginning on line 12, column 12.
A cfif tag beginning on line 12, column 12.
A cfif tag beginning on line 12, column 12.

The error occurred in C:\Inetpub\wwwroot\project1\upload.cfm: line 12
10 : <cfloop from="1" to="5" index="idx">
11 : <cfoutput>
12 : <cfif form.upload#idx# IS NOT "">
13 : <cffile action="upload" filefield="upload#idx#" destination="#request.siteURL#core/#NewUploadDir#/"
14 : nameconflict="makeunique" accept="image/*">
TOPICS
Advanced techniques

Views

240

Translate

Translate

Report

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
LEGEND ,
Jan 27, 2009 Jan 27, 2009

Copy link to clipboard

Copied

LATEST
nightwolf666 wrote:
> <cfif form.upload#idx# IS NOT "">

This is not the correct way to dynamically access a form field name.
The best practice is to use array notation. I.E. <cfif form["upload" &
idx] IS NOT "">

Votes

Translate

Translate

Report

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
Documentation