File blueprint: accept by file extension rather than mime type

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 HTML, you can filter by file extension like this:

<input type="file" accept=".kml">

I can even put

accept:
  mime: .kml

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…

Yes, I have a similar problem. In my case, I’m trying to separate file uploads into different sections in the Panel like this:

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.

      files:
        type: files
      images:
        type: files
        template: image
      vtt:
        type: files
        validate:
          endsWith:
            .vtt
        template: vtt
      srt:
        type: files
        validate:
          endsWith:
            .srt
        template: srt
      pdf:
        type: files
        template: pdf

I’m not even sure you can use validate here but I’m trying it.

Sections don’t have a validate property, only fields. Does this actually do what it should?

I can’t be sure. I’m only hacking away at it now.

Yeah, had stumbled upon your directions here: