Hi, I am trying to validate a File field in my form and it is always giving me empty error.
Here is my file field in the form
$facilityimage = new File('facilityimage');
$facilityimage->addValidators([
new \Phalcon\Validation\Validator\File([
'maxSize' => '0.5M',
'messageSize' => 'Your image is too big. Max file size: 500KB',
'allowedTypes' => array('image/jpeg', 'image/png'),
'messageType' => 'Your image must be a JPEG or PNG file',
'messageEmpty' => 'No image uploaded'
])
]);
$this->add($facilityimage);
In my Action, I have tried passing $_POST and $_FILES as follows:
if (!$form->isValid(array_merge($this->request->getPost(), $this->request->getUploadedFiles(true)))) {
foreach ($form->getMessages() as $message)
$this->flash->error((string) $message);
}
I have checked the forums and none of the solutions provided is working for now. I am using Phalcon 4.