Skip to content

Bug: ext_in validation rule not working on .stl files #9510

@Franky5831

Description

@Franky5831

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions