I don't know why but file validation is not working, it always return "Field :name must not be empty"
Example code:
<?php
use Phalcon\Validation;
use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\File;
if(!$_POST){
echo '<form method="POST" enctype="multipart/form-data">
<input type="file" name="cover" />
<input type="submit" name="test_button" value="Enviar">
</form>';
} else {
$validation = new Validation();
$validation->add('cover', new File([
"maxSize" => "2M",
]));
$validation->add('test_button', new PresenceOf([
'message' => 'The test button is required',
]));
$messages = $validation->validate($_POST);
if(file_exists($_FILES['cover']['tmp_name'])) {
echo 'File exists!!!<br>';
}
if (count($messages)) {
foreach ($messages as $message) {
echo $message, '<br>';
}
}
}
It returns:
File exists!!!
Field cover must not be empty
Im currently using PHP Version 5.6.25 and Phalcon 3.2.4...