Is there a way to limit file uploads, via a files section, to only a specific file extension?
I know there is the accept: mime: etc/etc property in the file blueprints. But, in the docs, I couldn’t find an option to restrict to a specific file extension instead.
Why?
Kirby doesn’t know about every existing mime type. For example .kml files are identified by kirby as text/html, while it probably would be application/vnd.google-earth.kml+xml or something like that. Even Chrome/Windows don’t know about that, and they wouldn’t accept it as filter for the “File Open” dialog.
in the file blueprint and the Windows “File Open” dialog will do its thing. But then Kirby rejects the upload because "text/html is not allowed" for security reasons (not allowing people to upload php files). But .kml is “almost never” (and certainly not on my server) treated as PHP.
I’d put this on github as feature request, but I’m not sure if I’m just not seeing something in the docs…
In tinkering with the file blueprints, some progress is made, one for each file type with blueprints/files/srt.yml:
title: SRT
accept: application/x-subrip
…
just under the blueprint title.
Files with .srt are mime: application/x-subrip and when it checks that, formatting of the uploaded file may not support that because the file is empty in some cases so it thinks that it is plain text.
Another one is: vtt (video captions) which is an mime: text/vtt, so when I try and upload that, and the file is also empty because it hasn’t been populated yet, the Panel will error since it isn’t in the vtt format:
My explorations with file suffixes and endings has been more productive.
In the blueprint for this page I’ve added various things that may be working, but finding documentation specific to this has been hard, since it’s such a different way of listing documents.