Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

E-dreamz_TP's avatar

[L5] Redactor WYSIWYG image upload not working with Csrf Token.

Wondering if anyone is using redactor wysiwyg editor and may have a solution for the TokenMismatchException Error when uploading an image. Redactor does a post to any route that you specify to your upload script. I don't want to update the redactor js, so that we can keep it up to date. Any ideas? It was working fine until recent composer updates.

0 likes
3 replies
bart's avatar

Did you check the token radactor sends?

lancis's avatar

I'm kind of late and not sure if you have solved this. But I used csrf by appending the token at the imageUpload setting

imageUpload: '/upload?_token=' + $('meta[name="_token"]').attr('content')

I used the example here for the token part

Disclaimer: I did this on commit 249f1858ac1c435dcb72ff4cd6f7b06c9e0cba91 and have not tested it again :)

2 likes

Please or to participate in this conversation.