0
我在Zend Framework 2應用程序中上傳圖片時出現問題,我想我的代碼中有一處配置錯誤。ZF2文件上傳:文件爲空
這是我現在的代碼。我創建瞭如ZfcUser窗體的窗體和過濾器。
表延伸ProvidesEventsForm(ZfcBase)
$file = new Element\File('image');
$file->setLabelAttributes(array('class' => 'control-label col-sm-4'));
$file->setLabel('image');
$this->add($file);
過濾器延伸ProvidesEventsInputFilter(ZfcBase)
$this->add(
array(
'type' => 'Zend\InputFilter\FileInput',
'name' => 'image',
'required' => true,
'validators' => array(
array(
'name' => 'File\UploadFile',
),
),
'filters' => array(
array(
'name' => 'File\RenameUpload',
'options' => array(
'target' => './public/img/uploads',
'randomize' => true,
),
),
),
)
);
在驗證過程的方法的FileInput :: isValid()的調用 - 但價值永遠是空的,我不知道它爲什麼。
HTML-Form設置爲multipart/form-data,服務器配置也沒有問題。 我用於測試的文件只有80KB。
任何一個想法,有什麼不對?