开发者

Coldfusion cfset and variable scope

I am trying to do this

<cfset noncooperativevariable = #serverfile#>

and I get a serverfile not 开发者_开发百科defined error. When I try to use the correct variable scope

<cfset noncooperativevariable = #CFFILE.serverfile#>

which returns the error.

You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members.

Edit:

<cffile action="upload" filefield="fileUpload" destination="#destination#" nameConflict="makeUnique" result="upload">
<cfset noncooperativevariable = #fileUpload.serverfile#>


When using the cffile tag, the results are defaulted to the cffile struct in your Variables scope. Therefore, if you are uploading a file with the following code:

<cffile action="upload" filefield="fileUpload" destination="#destination#" nameConflict="makeUnique" />

The results are accessible via the cffile struct in your Variables scope. The filename would be referenced as follows:

<cfset cooperativeVariable = cffile.serverfile />

In the snippet posted, you are using the 'result' attribute which would place your cffile results in the struct named upload instead of cffile, so you would get the filename like so:

<cfset cooperativeVariable = upload.serverfile />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜