2

I have a Laravel application and a form with dropzone. Normally , it works well. But when i try to upload large files ( 50M - 60 M), I get this error TokenMismatchException.

I'm using this code to send token :

formData.append("_token", $('[name=_token]').val());

I also changed all php.ini settings:

  • max_upload_size
  • set_time_limit(0);
  • memory_limit
  • post_max_size
  • max_input_time

As said above, it's working for small files.

Andrea
  • 11,801
  • 17
  • 65
  • 72
Tolga Ateş
  • 225
  • 1
  • 3
  • 14

2 Answers2

3

I solved the issue. It's because of php.ini file. I edited and saved php.ini but it didn't effect the output of phpinfo(); function. Output was showing old values. Check this link for solution :

Changes to upload_max_filesize in Ubunutu php.ini will not take effect

Community
  • 1
  • 1
Tolga Ateş
  • 225
  • 1
  • 3
  • 14
0

If you have changed all the php settings, that should not be an issue. However, if this is being done over AJAX, then appending a _token to the request is messy and hacky. Instead, set the {{ csrf_token }} as your request header. More specifically, set it on the X-CSRF-TOKEN header, since Laravel checks for that in the middleware.

Phroggyy
  • 423
  • 3
  • 10