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

BulkUploader: Adding UploadField Validation Not Working #189

Open
purplespider opened this issue Jan 30, 2019 · 3 comments
Open

BulkUploader: Adding UploadField Validation Not Working #189

purplespider opened this issue Jan 30, 2019 · 3 comments
Labels

Comments

@purplespider
Copy link
Contributor

I'm trying to add simple file type validation to the BulkUploader, but can't get it to work.

I've tried:
$bulkUpload->setUfSetup('setAllowedFileCategories', 'image/supported');
and also:
$bulkUpload->setUfSetup('setAllowedExtensions', ['jpg', 'jpeg', 'png', 'gif']);

But despite $bulkUpload->setUfSetup('setFolderName','XXX'); working fine, the above settings don't appear to have any effect.

Am I doing something wrong?

@robbieaverill
Copy link
Contributor

I have a feeling that this is the same bug as reported in silverstripe/silverstripe-cms#2294

@purplespider
Copy link
Contributor Author

Hmm, not sure if it is.

I tried adding $uploadField->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif')); to a Basic UploadField, and when I tried to upload a PDF, it correctly reported "Extension 'pdf' is not allowed".

But when I try and add this same restriction to the BulkUploader field, using $bulkUpload->setUfSetup('setAllowedExtensions', array('jpg', 'jpeg', 'png', 'gif')); it still accepts and uploads a PDF file.

So it does look like this issue is specific to BulkUploader.

@purplespider
Copy link
Contributor Author

I've delved into this a bit more, but can't work it out. It does seem like setFolderName is handled in a different place to setAllowedExtensions but I can't work out the intricacies of UploadField, UploadReceiver, FileUploadReceiver, FileField, FileHandleField etc to be able to work out what needs to change in BulkUploader to fix the validation failing to work.

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

No branches or pull requests

3 participants