-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Description
PHP Version
8.3
CodeIgniter4 Version
4.6.0
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
macOS
Which server did you use?
fpm-fcgi
Database
No response
What happened?
hey, i am using the codeigniter4 form validation, i want a input field to be used to upload multiple .stl files, so I did this:
Frontend:
<form action="<?= url_to("uploadModel") ?>" method="post" enctype="multipart/form-data">
<?= validation_list_errors() ?>
<input type="text" name="model_name" placeholder="Model Name">
<input type="file" name="cover" placeholder="Cover">
<input type="file" name="files[]" placeholder="Files" multiple>
<button type="submit">Upload</button>
</form>The controller:
$validationRules = [
'model_name' => [
'label' => 'Nome modello',
'rules' => 'required|max_length[255]',
],
'cover' => [
'label' => 'Cover',
'rules' => 'uploaded[cover]|is_image[cover]',
],
'files' => [
'label' => 'Files',
'rules' => 'uploaded[files]|ext_in[files,stl]',
],
];
if ($this->request->getMethod() == "POST" && $this->validate($validationRules)) {
$this->modelModel->save($this->request->getPost());
}I upload one or more .stl files $this->validate($validationRules) returns false and it does not passes the validation even tho it should.
Steps to Reproduce
- copy the code from above and try to upload a .stl file, you can remove the other 2 fields (model_name and cover)
- in Routes.php create the route for the controller and give it the required attribute:
$routes->match(['get', 'post'], $adminBaseRoute . "/upload-model", 'Admin::uploadModel', ["as" => "uploadModel"]);Expected Output
$this->validate($validationRules) should return true
Anything else?
Please let me know if i've been doing anything wrong
Metadata
Metadata
Assignees
Labels
No labels