Files with uppercase chars in name messes up the not() function

Hi all,

In my experience, when having a file with an uppercase character in it (e.g. “1-Test.png”), it messes up the $page->files()->not(“1-Test.png”) function?

Can someone confirm/fix this?

PS: if someone experiences the same, I’m currently working around this as follows:$page->files()->not(str::lower((string)$page->thumbnail()));

My hint:
Never use an uppercase character in a directory name or a file name on a webserver!
Then you will have no problems!!!

Please note, that most webservers in the internet use linux and this OS is case sensitive. Windows is case insensitive.
But this is no Kirby problem…

Good luck!

Of course, but if people decide to upload images with uppercased names (images are content after all), we might run into problems with the code we wrote :wink:

And btw, this is by all means no discussion about case sensitivity, linux, etc but the issuing of an unexpected kirby behaviour. This might be an edge case, but annoying to debug nonetheless.

If you type the filename in minuscules, it should work:


even if the filename itself is “1-Test.png”. This may be due to the fact that filenames are converted to lowercase by default in the files class.

Thanks for your reply Sonja.

Thats basically my workaround you’re describing :slightly_smiling:

The “problem” I have is that I use a filename coming from a variable in the markdown file generated from the file which is the directory. Rewriting it to lowercase does indeed solve the problem…

Took me a while to figure out though, and it was (is?) not expected behaviour.

That was only meant by way of explanation and might be due to the fact that different OS treat file names differently. But I agree that it is unexpected behavior if you suddenly come across this. Maybe we should put a hint in the docs.

Edit: But this behavior is not consistent, because e.g. $files->find() works only with capital letters if the filename is not lowercase, so this might be a bug after all.

This is most likely a bug. The $files object misses a specific not() method that works like the $pages->not() method. It uses the Collection->not() method instead, which does not support mixed case arguments.

I have opened an issue on GitHub. Meanwhile manually converting to lowercase is the only thing you can do.

Thanks everyone! :+1: