Restrict file types in file section?

Hello all. So you can’t restrict file types when creating a files section. Right? I’m just pretending the file section is really the file field I always wanted, but it’s not quite.

Yes, you can do that using a file blueprint with the accept property.

What did you want from the files field? Uploads for the files field are planned for the next feature release, it that’s what you’re missing right now.

I see. Right. That makes sense.

And yes. I always wanted a files field that allows you to upload one or many files direct to it so that’ll be a most welcomed feature.

Thanks Sonja. Should I just start out my questions with “Hello Sonja” next time? :smile: You’re always quick to reply. It’s greatly appreciated and part of the value I see in Kirby.

Oh no, please don’t! There’s a lot more to the community than me. And I’m not omniscient, anyway.

1 Like

No problem. Just give me your email address and I’ll send questions directly to you. I wouldn’t.

So bare with me a moment on this topic please… can I have 2 file sections on one page, one restricted to images, the other restricted to files? Guess not if both sections rely on the file blueprint. Or do I set that template option…

Yes, you can have as many files section as you want or as makes sense. If you assign a different file blueprint to each section, you can set different accept options for each section, e.g. one for images, one for PDFs etc.

In your template, you can then filter by these file blueprints to fetch only the files you need.

And how do you set the file blueprint? Is that what the template option is for?

Yes, exactly. Note that files sections can only ever have one template assigned to them (as opposed to pages sections where you can have multiple templates).

Gotcha, that’s not very clear in the docs, but it makes sense now that I know. Cool.

Where do you think should I add more information/restructure it to make this clearer?

The option as such is documented here: https://getkirby.com/docs/reference/panel/sections/files#filtering-files

Actually that’s pretty clear. I tend to scan that table, Section Properties for these little bits.

It currently reads, “Filters all files by template and also sets the template, which will be used for all uploads”, I suppose it would clearer for me if it read, "Filters all files by template and also sets the file blueprint, which will be used for all uploads.

The talk of templates throws me off.

Haha, yes, I understand. But then it should actually read " Filters all files by file blueprint and also sets the file blueprint.

And then the option should probably be called blueprint in the first place.

Same with pages, that problem already existed in Kirby 2.

Now you have to learn that in a Panel context a blueprint is the same as a template.

I agree.