Tincho.UY Tincho.UY - 5 months ago 295
PHP Question

Laravel 5.2 - TokenMismatchException in VerifyCsrfToken.php line 67:

I am creating a video upload system and when I submit a video it shows to me:


TokenMismatchException in VerifyCsrfToken.php line 67


I have this in my view:



<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" rel="stylesheet"/>
<form method="POST" action="{{ url('video/upload') }}" enctype="multipart/form-data" class="form-horizontal">
{{ csrf_field() }}
<fieldset class="form-group">
<label for="title">Title</label>
<input type="text" id="title" name="title" class="form-control">
</fieldset>
<fieldset class="form-group">
<label for="video">Video</label>
<input type="file" id="video" name="video" class="form-control">
</fieldset>
<fieldset class="form-group text-lg-right">
<button class="btn btn-success" type="submit">Upload</button>
</fieldset>
</form>





And this in my controller:

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Video;

use App\Http\Requests;

class VideoController extends Controller
{
public function upload()
{
return view('video.upload');
}

public function uploadPost(Request $request)
{
$this->validate($request, [
'title' => 'required|unique:videos|max:100',
'tags' => 'required',
'video' => 'required'
]);

$mime = $request->file('video')->getMimeType();

dd($mime);
}
}


And my php.ini is:


upload_max_filesize = 100M


Therefore, I have php.ini, csrf_field() and still getting error. What could be the issue?

Answer

post_max_size also needs to be raised, since it's throwing a POST Content-Length error.

Comments