SyntaxError: Unexpected token 'E', "ERROR [War"... is not valid JSON

Silverstripe Version: 3.7.0


I am trying to upload some images to my site and get the following error but only sometimes and there doesn’t seem to be a pattern to when it does and doesn’t work for me;

SyntaxError: Unexpected token ‘E’, “ERROR [War”… is not valid JSON

I’ve tried saving the images in different formats and as different sizes but no luck. The frustrating thing is that I have 3 sites (all using the same version of Silverstripe) and the same image will upload but one but not another.

Any help would be much appreciated!


The start of that “War…” suggest that something is throwing a warning in the back end. If you examine the request/response in your browser console, you may be able to see the full message… and that should give you some hints what the actual cause is.

Given the casuality, I would guess this is an encoding issue, i.e. when the filename is just plain ASCII it works fine, when it cannot be (e.g. the filename has accents or other non-ASCII symbols) it fails.

I’ve seen this very same issue many times and with different causes. JSON expects all the strings in UTF-8 encoding but maybe the filesystems on the failing servers are set to Latin1.