Coldfusion cfset 和变量范围
我正在尝试执行此操作
<cfset noncooperativevariable = #serverfile#>
,但出现服务器文件未定义错误。当我尝试使用正确的变量范围时
<cfset noncooperativevariable = #CFFILE.serverfile#>
,会返回错误。
您尝试将类 java.lang.String 类型的标量变量作为具有成员的结构取消引用。
编辑:
<cffile action="upload" filefield="fileUpload" destination="#destination#" nameConflict="makeUnique" result="upload">
<cfset noncooperativevariable = #fileUpload.serverfile#>
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#>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
cffile
标记时,结果默认为变量范围中的 cffile 结构。因此,如果您使用以下代码上传文件:可以通过变量范围中的 cffile 结构访问结果。文件名将按如下方式引用:
在发布的代码片段中,您使用“结果”属性,该属性会将您的 cffile 结果放置在名为 upload 的结构中,而不是 cffile 中,所以你会得到像这样的文件名:
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:The results are accessible via the cffile struct in your Variables scope. The filename would be referenced as follows:
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: