我在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#">
表面上它應該工作 - 你是否能夠發佈表單代碼和上傳處理代碼? – 2009-02-12 18:10:10
處理頁面是否使用任何包含或重定向?代碼很有幫助! – 2009-02-12 21:35:09
好的,我添加了代碼,表單和試圖發佈到的頁面。如果我刪除enctype,它發佈,但我得到錯誤「CF需要enctype ...」如果enctype attrib在那裏,它會嘗試查找頁面,但返回500錯誤。 – 2009-02-13 15:15:07