我在 Linux 上的 ColdFusion 中发布了一个表单。表单有一个文件字段。 CF 需要表单标签上的 enctype="multipart/form-data"属性。如果我有这个,我会得到一个“JRun Servlet Error - 500 No such file or directory”
如果我去掉 attrib,表单就会发布,我会收到 CF“enctype=multipart/form-data”错误。
怎么办?
下面是表格的精简版:
<form action="post.cfm" name="form2" id="port_form" method="post" enctype="multipart/form-data">
<input type="text" id="name" name="name" value="#port_name#"><br>
<input type="file" id="before" name="before"><br>
<input type="hidden" name="port_id" value="#port_id#" />
<button type="submit" name="post"> Post Portfolio Item </button>
</form>
这是我要发布到的页面 (post.cfm)
<cfif form.before neq "">
<cfinvoke component = "#application.cfcPath#.file" method = "upload" returnVariable = "beforeFile" theField="before">
<cfelse>
<cfset beforeFile = ''>
</cfif>
<cfif form.after neq "">
<cfinvoke component = "#application.cfcPath#.file" method = "upload" returnVariable = "afterFile" theField="after">
<cfelse>
<cfset afterFile = ''>
</cfif>
<cfinvoke component = "#application.cfcPath#.portfolio" method = "post" beforeFile="#beforeFile#" afterFile="#afterFile#">
<cfif form.port_id eq 0>
<cfset message = "The Portfolio Item has been successfully inserted.">
<cfelse>
<cfset message = "The Portfolio Item has been successfully updated.">
</cfif>
<cf_forward fuseaction="#fusebox.circuit#.home" message="#message#">
最佳答案
可能是服务器找不到上传的临时文件。
您是否尝试过不使用组件包装器进行上传?
简单
<cfif StructKeyExists(Form, "before") AND Form.before NEQ "">
<cffile
action="upload"
filefield="before"
destination="#AbsPathToStoreFile#"
>
</cfif>
<cfdump var="#cffile#">
如果失败,也许您将能够看到更多详细信息。
关于linux - ColdFusion/Linux multipart/form-data 编码文件上传问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/542396/