文件上传时,Coldfusion 返回: C:\ColdFusion8\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp12429.tmp 不包含文件

发布于 2024-08-13 18:22:10 字数 783 浏览 13 评论 0原文

文件上传后,Coldfusion 8 返回: C:\ColdFusion8\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp12429.tmp 不包含文件。有谁知道这可能是什么原因造成的?语法不好?服务器权限?缺少碎片?

我的 cfform 标签如下所示:

<cfset myPath = "path to my folder">
<cfset mimeTypesList = "list of mime types I can accept">

<cfif structKeyExists(FORM, "submit")>
    <cffile action="upload" fileField="#form.myImage#" destination="#myPath#"
accept="#mimeTypesList#" nameConflict="MakeUnique">
</cfif>

<cfform name="myForm" format="html" action="#cgi.SCRIPT_NAME#" method="post" enctype="multipart/form-data">
<cfinput type="file" name="myImage" accept="image/jpg,image/gif,image/pjpeg">
<cfinput type="submit" name="submit" value="submit">
</cfform>

Upon file upload, Coldfusion 8 returns: C:\ColdFusion8\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp12429.tmp did not contain a file. Does anyone know what may cause this? Bad syntax? Server permissions? Missing pieces?

My cfform tag looks like the following:

<cfset myPath = "path to my folder">
<cfset mimeTypesList = "list of mime types I can accept">

<cfif structKeyExists(FORM, "submit")>
    <cffile action="upload" fileField="#form.myImage#" destination="#myPath#"
accept="#mimeTypesList#" nameConflict="MakeUnique">
</cfif>

<cfform name="myForm" format="html" action="#cgi.SCRIPT_NAME#" method="post" enctype="multipart/form-data">
<cfinput type="file" name="myImage" accept="image/jpg,image/gif,image/pjpeg">
<cfinput type="submit" name="submit" value="submit">
</cfform>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

£烟消云散 2024-08-20 18:22:10

我解决了这个问题,它很微妙,但很容易被忽视。

cffile 标记的 fileField 属性只是询问文件输入的名称,而不是生成的 Coldfusion FORM 变量。

错误:

<cffile action="upload" fileField="#form.myImage#" ...

正确:

<cffile action="upload" fileField="myImage" ...

I solved the problem, it's subtle, but easy to overlook.

The cffile tag's fileField attribute is simply asking for the name of the file input, NOT the resulting Coldfusion FORM variable.

Wrong:

<cffile action="upload" fileField="#form.myImage#" ...

Right:

<cffile action="upload" fileField="myImage" ...
三生路 2024-08-20 18:22:10

上面的答案是正确的,但只是想补充一下,以防有人我已经解决了我的相关问题。

我原来的图片上传代码是这样的;

<cfobject component="#session.components#files" name="files">
<cfset url_file_path = files.uploadImage(file_upload)>

这导致了标题中提到的类似错误(C:\ColdFusion8\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp12429.tmp)。

当我将代码更改为;

<cfinvoke component="#session.components#files"
method="uploadImage"
formField = "file_upload" 
returnvariable = "url_file_path">

一切都很帅!老实说,我不知道为什么,但只是需要注意一下。

The answer above is correct but just wanted to add to it in case anyone my related issue which I have resolved.

My original image upload code was like this;

<cfobject component="#session.components#files" name="files">
<cfset url_file_path = files.uploadImage(file_upload)>

This caused a similar error mentioned in the title (C:\ColdFusion8\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp12429.tmp).

When I changed my code to;

<cfinvoke component="#session.components#files"
method="uploadImage"
formField = "file_upload" 
returnvariable = "url_file_path">

All was hunky dorey! To be honest I don't know why but just something to look out for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文