2012-09-05 90 views
1

我想使用此代碼上傳文件到我的服務器,但給我一個錯誤。CFFILE上傳所有問題 - Coldfusion 9

這是代碼:

<cfif isdefined("form.submit")> 
    <cffile action="uploadall" destination="#expandpath('../../images/Uploads/after')#"> 
</cfif> 
<cfform action="#cgi.script_name#" enctype="multipart/form-data"> 
    <cfinput type="file" name="attachment1"><br> 
    <cfinput type="file" name="attachment2"><br> 
    <cfinput type="file" name="attachment3"><br> 
    <cfinput type="submit" name=" submit" value="submit"> 
</cfform> 

這是錯誤:

The following information is meant for the website developer for debugging purposes.

Error Occurred While Processing Request

Invalid content type: application/x-www-form-urlencoded.

The files upload action requires forms to use enctype="multipart/form-data".

The error occurred in E:\sites\Example.Com\testing\handlers\upload\after.cfm: line 20

+1

是你運行CF9還是9.0.1?在9.0.1更新程序中修復了CF9原始版本中的文件上載控制問題。 – Brian

+0

我正在使用9.0.1 – Geo

回答

1

我看到你已經轉向了另一種解決方案,但我想回答你的問題,因爲答案顯然很瘋狂(並且是Coldfusion中一些奇怪陷阱的刻板印象)。問題是<cfform> simply doesn't support the enctype attribute。如果你想上傳文件,你必須使用普通的<form>。奇怪,對吧?

(我想是這樣,隨着該ENCTYPE文件輸入結果的CFFORM被正確自動設置你可以改變XSLT,但它爲什麼不這樣做開箱即用的我是無法理解。)

+0

我要去測試一下!是我想的最後一件事情,因爲我會假設如果cfform不支持​​enctype,那麼純文本也不會。謝謝! – Geo

+0

其實它是支持的。額外的HTML屬性直接傳遞到'

'標籤。 – Leigh

0

請問你是在目標屬性引用的目錄結構存在 '「#expandpath(' ../ ../images/Uploads/after')#「」?

如果destination屬性不是絕對路徑,那麼它是相對於ColdFusion的臨時目錄。不相對於您的web根目錄或正在運行的模板。

下面是從文檔here

中上傳的文件目錄的路徑名的說明。如果不是絕對路徑(以驅動器號和冒號或前向或後向斜線開始),則它與ColdFusion臨時目錄相關,後者由GetTempDirectory函數返回。

+0

路徑是正確的。這是我發佈我的問題之前要檢查的第一件事 – Geo

+0

另一個問題可能是ColdFusion沒有該目錄的權限。您是否嘗試將目標更改爲臨時目錄本身#expandpath('./ uploads')#以查看問題是否仍然存在? –

+0

是的,我也是這麼做:) – Geo