ColdFusion / Linux multipart / form-data编码文件上传问题

时间:2009-02-12 17:19:32

标签: linux forms coldfusion enctype

我在Linux上的ColdFusion中发布了一个表单。表单有一个文件字段。 CF要求表单标记上的enctype =“multipart / form-data”属性。如果我有这个,我得到一个“JRun Servlet错误 - 500没有这样的文件或目录”

如果我取出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#">

3 个答案:

答案 0 :(得分:1)

可能的原因是服务器无法找到上传的临时文件。

您是否尝试过不使用组件包装器进行上传?

简单地

<cfif StructKeyExists(Form, "before") AND Form.before NEQ "">
<cffile
    action="upload"
    filefield="before"
    destination="#AbsPathToStoreFile#"
    >
</cfif>

<cfdump var="#cffile#">

如果失败,您可能会看到更多细节。

答案 1 :(得分:0)

您可能已经尝试过此操作,但您是否尝试过路径和文件名中的所有大写或全部小写?有时CF会破坏大小写的东西。

答案 2 :(得分:0)

我想知道CF试图将文件保存到的临时文件夹是不可访问(权限)还是未正确配置。

您应该尝试使用CFFILE标记并指定您有权访问的文件夹。

相关问题