form.php
$attachment = new FileAttachment('attachment');
$attachment->addValidators(array(
new FileValidator(array(
'maxSize' => '2M',
'messageSize' => ':field exceeds the max filesize (:max)',
'allowedTypes' => array(
'application/pdf',
'application/msword',
'application/vnd.ms-excel',
'text/plain',
'image/gif',
'image/jpg',
'image/png',
'image/bmp',
'image/jpeg',
'application/x-compressed',
'application/x-zip-compressed',
'application/zip',
'multipart/x-zip',
'application/x-rar-compressed',
),
'messageType' => 'Allowed file types are :types',
'allowEmpty' => true
))
));
$this->add($attachment);
action.php
$submitRequestForm = new submitRequestForm();
if (!$submitRequestForm->isValid($_POST)) {
foreach ($submitRequestForm->getMessages() as $message) {
$messages .= '<li>'.$message.'</li>';
}
$app->flashSession->error($messages);
$app->session->set('requestForm', $_POST);
return $this->response->redirect($this->request->getServer('HTTP_REFERER'));
exit;
}
what would a file in a form is not loaded, always answers: "Field attachment must not be empty".
tried different files, always says the same thing