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

nikocraft's avatar

when uploading files that exceed php limit TokenMismatchException happens

I am building a website where users can upload images. Just to test what happens if I upload images that go over default php limit of 8mb I uploaded 12 mb worth of images, I then see this: http://i.imgur.com/qFeSMdH.png?1

Warning: POST Content-Length of 13678792 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 Whoops, looks like something went wrong. 1/1 TokenMismatchException in VerifyCsrfToken.php line 67:

i then edited php.ini and did this display_errors=Off and tried again and this time I got just 1/1 TokenMismatchException in VerifyCsrfToken.php line 67:

Why do I get tokenmismatch when I try to upload above limit specified in php.ini, it doesnt happend If I stay below limit

0 likes
1 reply
ohffs's avatar

I hit this before and didn't really look into it much - but I assumed it means when the file size limit is reached there is an empty $_POST given to PHP so it can't see the _token (or anything else). I was going to try disabling csrf for that one method just to check that the $request was empty - but then it turned out I was too lazy and/or busy ;-)

Please or to participate in this conversation.