Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jakejackson1 opened this issue Jul 7, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@jakejackson1
Copy link
Member

jakejackson1 commented Jul 7, 2022

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());
    }
}

?>
@jakejackson1 jakejackson1 added the bug Something isn't working label Jul 7, 2022
@jakejackson1 jakejackson1 changed the title Multiple Upload Field Validation Failure Prevents Valid Files Being Saved Upload Field Validation Failure Prevents Valid Files in Multiple File Field Being Saved Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant