TL如果驗證失敗,與可選文件; DR:Zend_Form_Element_File不打尼斯IE10Zend_Form的IE10中
好吧,包涵我,而我解開這個故事我一生中遇到最嚴重的錯誤之一。 (僅適用於IE10)
我用Zend_Form的(Zend框架1.12)與Zend_Form_Element_File:
$file = (new Zend_Form_Element_File('file'))
->setRequired(false);
我還使用jQuery Form Plugin使用AJAX或iFrame的適當時候。 (這是一個新的發展,以前我只使用一個iframe [和該版本中發現此錯誤],並且因爲我將iframe移到了XHR2 Feature Detected中)。
所以我們有這種形式,AJAXly提交文件和其他變量到服務器,它試圖通過Zend_Form來驗證它。沒什麼大不了。 Chrome和Firefox發送Zend檢測到的空文件並且沒有問題,並且IE正在發送與該文件相關的任何內容,並且現在正在發送一個名爲file的空參數(不是空文件),而Zend_Form則說「文件太大「。
的文件數組是空的,所以我實現了補丁建議對Zend的問題ZF-12189獲得:
$check = $this->_getFiles($files, false, true);
if (empty($check)) {
if ($this->_options['ignoreNoFile']) {
return true;
}
return false;
}
但$check
不作爲評估的empty
問題仍然存在。
相關的請求報頭:
X-Requested-With: XMLHttpRequest
Accept: text/html, */*; q=0.01
Content-Type: multipart/form-data; boundary=---------------------------7dd299161d06c6
Content-Length: 580
請求正文:
-----------------------------7dd299161d06c6
Content-Disposition: form-data; name="entryId"
9
-----------------------------7dd299161d06c6
Content-Disposition: form-data; name="csrf"
b9774f3998695465d9b3079eb028e342
-----------------------------7dd299161d06c6
Content-Disposition: form-data; name="description"
test
-----------------------------7dd299161d06c6
Content-Disposition: form-data; name="MAX_FILE_SIZE"
2097152
-----------------------------7dd299161d06c6
Content-Disposition: form-data; name="file"
-----------------------------7dd299161d06c6--
形式消息:
{"file":{"fileUploadErrorIniSize":"File 'file' exceeds the defined ini size"}}
有誰知道一個解決這個問題的?
這裏是黑客Zend_Form的修復問題的解決方法 - http://stackoverflow.com/a/32472069/5207687 – Clay
@Clay IIRC,我用了一個類似的修復。如果你想發佈這個答案,我很樂意接受它 – Navarr
發佈它作爲答案:-) – Clay