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

Snapey's avatar
Level 122

Large file upload gives csrf token mismatch

Not really a question, but an observation for anyone with the same issue.

If you are trying to upload large files, you can increase the php upload_max_filesize from the default 2M to, say 10M but if you don't also increase the setting post_max_size, what happens is that the posted input is truncated and the csrf token is not passed through.

This results in a csrf issue for some file sizes (files below the upload_max_filesize, but larger than post_max_size.

One other tip, if you are using Valet, for development, be sure to run valet restart after changing the values

0 likes
0 replies

Please or to participate in this conversation.