Gojko_Che's avatar

Images not displaying due to special chars in the file name

Whenever I upload a file through my app, that contains letters like č, or š, the file name is changed to some weird character ( šir). I suppose that is due to encoding, but I haven't find the solution. The name is properly stored in the database.

0 likes
5 replies
ahuggins's avatar

when accessing the path in your view, what is the output? does it have the special characters or not?

You may have to use utf8_encode() in order to encode the characters. May have to do this on insert to db, or when displaying. Play around with it.

ahuggins's avatar

Oh and if you are doing anything with JSON, I think everything needs to be utf-8 encoded otherwise JSON rejects it.

Gojko_Che's avatar

Hi, thank you for your response. Image name is displaying correctly, and it is stored in the db correctly, only when the file is stored in the file system, it gets corrupted :). Tried utf8_encode() but it didn't do the trick.

ahuggins's avatar

What do you mean "stored in the file system"?

Always helpful to post sample values!

Gojko_Che's avatar

Hi, I managed to correct it just now. It seems that it is something to do with Windows encoding, because I as soon as I changed to Linux, it all works perfectly. Thanks again.

Please or to participate in this conversation.