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

AnriKo's avatar

TokenMismatchException with big files

I render token field in my form

<form method="POST" action="http://mi.com/zak" accept-charset="UTF-8" enctype="multipart/form-data">
<input name="_token" type="hidden" value="T0T73F8F13mDZK2BiLG74D1h6XfKkJqcpuMQuDj4">

Form have input file, and input text with value of base64 generate img code. And when I upload small images all is well but when I try to upload img more than 200KB (on real hosting) I get error

TokenMismatchException in compiled.php line 3227

I do not understand how this could be connect with the large file. Do you have any idea why this is happening and how this can fix?

0 likes
5 replies
ejdelmonico's avatar

Is your upload being chunked? If so, that might be why. Check for it in network tab of dev tools.

ohffs's avatar
ohffs
Best Answer
Level 50

That can also happen if the file is bigger than your php/webserver is set to allow (it's quite annoying) :-/

1 like
AnriKo's avatar

Yes this is happen because php/webserver is set to not allow big file. And I do not understand why, then, such an error TokenMismatchException is issued. Thanks for the help.

murph133's avatar

Solution:

Yes, you need to update your php.ini file.

Yes, increase the upload_max_filesize and post_max_size, but ALSO increase the max_execution_time.

I had a problem when a user tried to upload a 13mb image. When I increased the max_execution_time from 30 to 90 seconds, this resolved the issue.

1 like

Please or to participate in this conversation.