Allowed File Extensions

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 31, 2019   (RSS)

By daniel - October 30, 2019

Hi Greg,

To answer your specific question: you can use the function getSchemaFields($sectionName) to return an array of all the fields in that section, then you can search through the returned array to look for the upload field in question. The "allowedExtensions" property of that field should contain the extensions configured in the section editor.

However, note that this will be a list of fileĀ extensions which is different from the mime-type required by your JS snippet. Some possible solutions are to modify your JS to check file extension rather than mime-type or find a list of extensions<->mime-type that could be used to map the correct values.

If you're using CMSB functions to perform the upload, also note that there's a danger in checking for mime-type on the front end and extension on the back end (current CMSB behaviour), as they are generally related but fundamentally different things. This can lead to false positives/negatives in edge cases. This is why JS file-type checking is disabled for the default CMSB uploader, as our current library is only able to check for mime-type and not the extension.

Let me know if you have any questions, or if I can help with anything else!


PHP Programmer

By gversion - October 31, 2019

Hi Daniel,

As always, you've been extremely helpful - thank you very much!