1up-lab / OneupUploaderBundle

This Symfony bundle provides a server implementation for handling single and multiple file uploads using either FineUploader, jQuery File Uploader, YUI3 Uploader, Uploadify, FancyUpload, MooUpload, Plupload or Dropzone. Features include chunked uploads, orphanages, Gaufrette and Flysystem support.
MIT License
603 stars 177 forks source link

Catch uploads bigger than upload_max_filesize #405

Closed knallcharge closed 2 years ago

knallcharge commented 3 years ago

Question

I'm trying to catch an error when a user uploads a file bigger than upload_max_filesize, but the file just passes the upload (checkmark is shown in the frontend), not calling the configured onValidation-event and not actually saving the file.

I'm using dropzone and have configured two methods in my services.yaml (onUpload, onValidation) as described here https://github.com/1up-lab/OneupUploaderBundle/blob/master/doc/custom_validator.md:

    app.upload_listener:
        class: App\EventListener\UploadListener
        arguments: [ "@doctrine.orm.entity_manager","@security.token_storage" ]
        tags:
            - { name: kernel.event_listener, event: oneup_uploader.post_upload, method: onUpload }
            - { name: kernel.event_listener, event: oneup_uploader.validation, method: onValidation }

Both methods are called with a small file which is processed correctly. But when I upload a 14MB JPG (upload_max_filesize and post_max_size set to 2M), both methods are never called while the file is still being rejected. I also added a custom error handler (as seen here: https://github.com/1up-lab/OneupUploaderBundle/blob/master/doc/custom_error_handler.md) as I thought the error might show up there, but it is also never called when uploading a file that's too big.

The problem now is, that I never get a chance to catch the error and the user sees a checkmark in the frontend, thinking that everything's fine, but the file never gets saved and processed.

This is my config:

oneup_uploader:
    mappings:
        gallery:
            namer: app.safe_uniqid_namer
            frontend: dropzone
            max_size: -1
            error_handler: app.upload_error_handler
            storage:
                directory: "%app.path.uploads%"
Q A
Version 3.1.2
bytehead commented 3 years ago

Do you have any call stack (Symfony debug toolbar) from the failing request?

knallcharge commented 3 years ago

Unfortunately not as the request is not failing (which is probably the core of the problem?).

I see this this after the upload in the dropzone-area, indicating "OK" to the user: grafik

This is my toolbar (tried 3 times): grafik

Info from the Request: grafik

And the Response: grafik followed by 14MB data (from the uploaded file)

That's it, no error and no uploaded file while the user thinks everything went ok.

bytehead commented 3 years ago

which version of Symfony and PHP are you using?

knallcharge commented 3 years ago

latest / latest grafik

bytehead commented 3 years ago

Thank you. Please give me some time to look into this 🙃

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

knallcharge commented 3 years ago

The problem persists, any news on this?

bytehead commented 3 years ago

Not yet, I'm afraid.

knallcharge commented 3 years ago

Addition (in case that matters): the above behaviour is shown in a Windows environment (IIS) as well as XAMPP on Windows (can't test Linux).

Workaround as I had to get this working:

That works as long as the uploaded size is below 20MB (an error is shown if it's above 5MB), so the issue only happens when the system-limit is exceeded. Still not a great solution (fingers crossed that nobody uploads something bigger than 20MB) but better than having users thinking their uploads are fine while they're not.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.