Skip to content

Upload Field Validation Failure Prevents Valid Files in Multiple File Field Being Saved #14

@jakejackson1

Description

@jakejackson1

I found this bug

When allowing multiple files to be uploaded via a single file input field, if one of those files fails the validation check any subsequent files will not be processed.

This is Upload and PHP version and environment (server/fpm/cli etc) I am using

Upload 2.0.0 and PHP7.4

This is the HTML/CSS code snippet I use for the form

<form method="POST" enctype="multipart/form-data">
    <input type="file" name="foo[]" value="" multiple/>
    <input type="submit" name="submit" value="Upload File"/>
</form>

This is the PHP code snippet I use after form submission

<?php

require __DIR__ . '/vendor/autoload.php';

if (isset($_POST['submit'])) {
    $storage = new \GravityPdf\Upload\Storage\FileSystem(__DIR__ . '/upload/');
    $file = new \GravityPdf\Upload\File('foo', $storage);

    $file->addValidations([
        new \GravityPdf\Upload\Validation\Mimetype('image/png'),
        new \GravityPdf\Upload\Validation\Extension('png'),
        new \GravityPdf\Upload\Validation\Size('5M'),
    ]);

    try {
        // Success!
        $file->upload();
    } catch (\Exception $e) {
        // Fail!
        print_r($file->getErrors());
    }
}

?>

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions