Support the ongoing development of Laravel.io →
Security Session Forms
Last updated 2 years ago.
0

I had the same error when uploading files which were to large for my server. I'm not sure why you get the error even though your max is 2G, but I can give you a solution (sort of).

The reason you get a TokenMismatchException is that somehow the server clears all of the $_POST and $_GET variables. I couldn't find a way to ignore this behavior, so I made a filter which will throw a more appropriate exception when the the uploaded file is to large.

https://gist.github.com/MarkRedeman/9125186

So it's not really a solution to your problem, but at least you will get a more appropriate exception.

Last updated 2 years ago.
0

Thank you. At least it's not me going crazy thinking I don't have a parameter set properly. Now I know what the issue is. Unfortuatenly I think I'm going to have to disable the CSRF for this form to get this to work for now.

Last updated 2 years ago.
0
Solution

if you upload more then your server's post_max_size setting the input will be empty, hence a token miss-match

so if you have 2 upload input's in your form and your upload_max_filesize is 2G, your post_max_size needs to be at least 4G

Last updated 2 years ago.
0

@zenry

Woot! That did it! Thank you! Would never have guessed that!

Last updated 2 years ago.
0

Thank You!!!

Spent literal hours thinking that I had a weird bug. I'm surprised Laravel doesn't have a built in exception error for files that are too large. Finally, I can move on with my project!

0

On thing that happened to me.

In case you are running php server with php -S, restart it to let php.ini changes take effect.

I was running it and restart apache server, but I was actually using php -s command.

I hope it saves someones time.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

vstokesjr vstokesjr Joined 17 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.