File upload breaks on some files?

Hello there,

I got a problem with Kirby when I want to upload files. This does not happen with all files but with some.
To follow along i recorded a short gif video:

As you can see I am using a fresh 2.3 Kirby installation. However the bug also appears in version 2.2 where I first encountered it so I wanted to know if updating to 2.3 would solve it.

The files I uploaded was a simple .js file and a text file:

  • test.js had the content: var hello = ‘hello World’;
  • textfile.txt had the content: hello

The full error description is in this picture:

Any thoughts on this one? Maybe you can reproduce this error?

Greetings

Do you have the same error message when you Upload some image’s files like png,jpg,gif ?

I can upload pdf’s, images and so on and got no problems or errors there.

As far as I can remember, there was an issue with uploading files of type txt, js etc.; trying to find it …

Edit: With txt files you will most probably run into an issue, anyway, because the panel might not recognize the right file anymore, and maybe not even Kirby.

I just tested with a js file and did not have a problem. txt does not seem to work though.

So as the error message suggest, it seems to be a mime type error?

What is the text encoding of your files? UTF-8 or something strange?

@lukasbestle how do I check this? I created the files on my desktop via visual studio code and also with sublime text 3. It is really strange because I got other .js files where it is working without problems.

Edit:
In visual studio code it says that the encoding is UTF-8.

Maybe this is due to UTF-8 with or without BOM, check if your encoding is without BOM in VS code.

I don’t know exactly how I can control the BOM in VS Code (nothing on google either)

What I did for now is creating files with all those combinations of:

  • CRLF or LF end of line sequence
  • files.eol: “\n” or “files.eol”: “\n\r” (default end of line character)

All of them pass, when the file is empty. But if I just add a simple line of code they produce the above error.

This really gives me some trouble because I can not make sure, that the users will upload proper mime type .js files or what ever. Also the editors who will get the content into the CMS are not programmers or someone who can change the mime type or file type (if this is really the cause of the problem) to get it working (and they should not be bothered with something like that either).

I fully agree with you here. It’s a bug and we need to fix this, but before we need able to reproduce the error. :slight_smile:

I will test if the problem arises on my laptop.

Maybe you could try my .js files and see If the error is occurring for you now too.

I tested this on my local dev server and all 4 files were uploaded without any problem.

@texnixe what dev server software do you use for development?

I’m on a Mac and use MAMP.

I tested it as well and all files worked for me. I’m also on OS X.

What would interest me: Your GIF shows the success smiley at the top right. What happens if you reload the Panel page after the upload? Is the file displayed then? Or maybe the error message is still there?
Could you please also check if the files are in the content folder after uploading? They should be judging by the smiley.

@lukasbestle When I press refresh the error message is still there yes. You can see it in the screenshot. There is this little icon and the error message. I can click on that icon and delete the file from there. The file is uploaded properly however and gets displayed in the content folder.

That’s interesting. It means that the upload itself works fine, only the mime detection to display the sidebar fails. I have created an issue on GitHub.

1 Like

A post was split to a new topic: Can’t upload JPG files

thanks for the effort @lukasbestle