Search code examples
phplaravelroutestokenmismatch

TokenMismatchException in VerifyCsrfToken on certain pdf files


I have a strange issue with laravel. I am working on a project with a file upload in it. everything works fine except for one pdf file i have on my machine. with that pdf file i get a TokenMismatchException. I tried it on an other projects and exactly the same error.

Here is my HTML:

<form method="POST" action="" enctype="multipart/form-data">
  {!! csrf_field() !!}
  <div class="form-group{{ $errors->has('file') ? ' has-error' : '' }} row">
      <label class="col-md-2 control-label" for="file">Bestand</label>
      <div class="col-md-4">
          <input type="file" name="file">
          @if ($errors->has('file'))
              <span class="help-block">
                  <strong>{{ $errors->first('file') }}</strong>
              </span>
          @endif
      </div>
  </div>
  <div class="row">
      <div class="pull-right">
          <button type="submit" class="btn btn-primary btn-orange">
              Opslaan
          </button>
      </div>
  </div>
</form>

And here is my route:

Route::post('footer-toevoegen', function () {
    dd(\Request::all());
});

And the pdf:

Here


Solution

  • Can you check php.ini config ?

    php.ini

    post_max_size=20M
    upload_max_filesize=20M