I get the message “Forbidden mime type” when I try to upload a svg file to a page in the Panel. I use version 2.2.2 of the Toolkit, Kirby and Panel. I have the problem on both my MAMP and an external Ubuntu / Apache server.
to the .htaccess just in case, but still the same problem.
I can use the svg image in the Panel and on the page if I manually put it in the folder structure, but I want to use the Panel to add the file.
So it’s what I thought. Hm, that’s really strange. I honestly don’t know how to fix it in PHP 5.6, as the MIME detection is built-in to PHP.
Hopefully someone else had this problem before and can give some input.
But still getting text/html for the svg mime type. I tried to remove the # for application/vnd.oipf.dae.svg+xml and restarted the server. But still the same.
What to do?
The Apache MIME file shouldn’t contribute anything to the PHP MIME detection. Maybe your system magic file, but as far as I know, PHP has its own set of information about file types.
I now tried to upload a svg to a Kirby installationen on a third and different server. Still the same problem. I can’t be the only one having this struggle?
I just tested it again. It seems like the detection algorithm PHP uses also checks whether the SVG file has a <?xml version="1.0" encoding="UTF-8" standalone="no"?> line at the beginning. When run through SVGO (which removes that) or just when deleting that line, PHP detects the file as HTML.
I have no problem uploading an svg file with that line removed though, so that is probably not the problem although it would be interesting to know if the file you want to upload misses the xml tag.
That did the trick!
But that is just annoying. I run all my svg through the optimizer at http://petercollingridge.appspot.com/svg-editor and tell my clients to do the same. But now I need to tell them to add this line… or not to optimize (which is probably easier but boring).
What settings do you use to optimize the files? I tested this and could still upload an optimized file (tested on localhost and two remote servers). So I wonder if there is something else to it.
I tried that with a couple of files, and all files could be uploaded. Having said that, the mime type of these files is recognized as text/plain, not text/hmtl, that’s probably why it does work.
Yes, the Panel only blocks HTML, PHP, EXE types and files with extension txt (Kirby content file). Every other type is fine, no matter what it actually is.