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

Add min/max file size limits by mime type. #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

willvincent
Copy link

Closes issue #3.

Adds optional mimeMinFileSizes and mimeMaxFileSizes config options, these should work in conjunction with existing min/max and max total limits, and allow for setting min or max limits by explicit mime type or mime type wildcard group:

ie:

<script>
        // Register the plugin with FilePond
        FilePond.registerPlugin(FilePondPluginFileValidateSize);

        // Get a reference to the file input element
        const inputElement = document.querySelector('input[type="file"]');

        // Create the FilePond instance
        const pond = FilePond.create(inputElement, {
            mimeMaxFileSizes: {
                'image/*': '3MB',
                'image/gif': '5MB',
                'video/mp4': '100MB'
            }
        });
</script>

That config will allow images of any type up to 3mb, but allow gifs to be up to 5mb, and restrict mp4 videos to 100MB.

@rikschennink
Copy link
Collaborator

Appreciate the PR, will consider for v5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants