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

xScence's avatar

Laravel 5.3 TokenMismatchException

Hello guys. I have a simple form:

<form method='POST' action='/some/action' enctype='multipart/form-data'>
<input type="text" name="firstname" />
<input type="text" name="lastname" />
<input type="file" name="image-file" />
{{ csrf_field() }}
<input type="submit" name="submit" value="submit" />
</form>

When i post the fields (firstname, lastname) everything is ok. But if i choose also an image or any kind of file, i get error that TokenMismatch. How could i fix this ? Thanks!

0 likes
4 replies
ejdelmonico's avatar

Try moving the {{ csrf_field() }} to just below the form tag. Sometimes, you get inconsistent taken matching if its not first....at least in the times I have had trouble.

xScence's avatar

No change ;/ still the same.

p.p This is happening when i select bigger size files. Like 50+ MB

Tirke's avatar
Tirke
Best Answer
Level 8

Yeah, I don't see how moving the field up is going to change anything (but it's pretty standard to have it first).

This is really a strange issue because you are saying that it's working without the file and you do have multipart set....

EDIT 1 :

AH okay, big files = need to check apache settings or whatever web server you are using for max_upload limit

1 like
xScence's avatar

Thank you @Tirke the problem was that the max upload filesize were 8MB (max) when i extend the MB's there is no problem. Cheers!

1 like

Please or to participate in this conversation.