2009-02-12 57 views
1

我在Linux上的ColdFusion中發佈表單。表格有一個文件字段。 CF需要表單標籤上的enctype =「multipart/form-data」屬性。如果我有這個,我得到一個「JRun Servlet的錯誤 - 500沒有這樣的文件或目錄」ColdFusion/Linux多部分/表格數據編碼文件上傳問題

如果我把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#"> 
+0

表面上它應該工作 - 你是否能夠發佈表單代碼和上傳處理代碼? – 2009-02-12 18:10:10

+0

處理頁面是否使用任何包含或重定向?代碼很有幫助! – 2009-02-12 21:35:09

+0

好的,我添加了代碼,表單和試圖發佈到的頁面。如果我刪除enctype,它發佈,但我得到錯誤「CF需要enctype ...」如果enctype attrib在那裏,它會嘗試查找頁面,但返回500錯誤。 – 2009-02-13 15:15:07

回答

1

可能的原因是服務器無法找到上傳的臨時文件。

您是否嘗試過無組件封裝的上傳?

只需

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

<cfdump var="#cffile#"> 

如果失敗也許你將能夠看到更多的細節。

0

,但你在路徑和文件名中嘗試了所有大寫或全部小寫?有時CF會打破大小寫的東西。

0

我在想如果CF試圖保存文件的臨時文件夾是無法訪問(權限)或沒有正確配置。

您應該嘗試使用CFFILE標記並指定您有權訪問的文件夾。

相關問題