简体   繁体   English

上传视频时,VerifyCsrfToken.php 67行中的TokenMismatchException

[英]TokenMismatchException in VerifyCsrfToken.php line 67 when uploading video

图片1 uploadscontroller

Picture 2 Form 图2表格

Picture 3 Form 图片3表格

Hi, 嗨,

I'm getting the error mentioned in the title when trying to upload a video using Laravel 5.2. 尝试使用Laravel 5.2上传视频时,出现标题中提到的错误。

Images work correctly. 图像正常工作。

I've checked the PHP.ini settings of my MAMP server. 我已经检查了MAMP服务器的PHP.ini设置。

I'm using the form facade so I don't have to import token into my form. 我正在使用表单外观,因此不必将令牌导入到表单中。

I'm clueless, does anybody have suggestions what it might be? 我一无所知,有人建议它可能是什么吗?

<div class="container spark-screen">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <div class="panel panel-default">
                <div class="panel-heading">Bestand uploaden</div>

                <div class="panel-body">
                    {!! Form::open(
                        array(
                            'url' => 'uploads',
                            'class' => 'form',
                            'novalidate' => 'novalidate',
                            'files' => true)) !!}

                        @include('uploadspanel.create_form')

                    {!! Form::close() !!}
                </div>
            </div>
        </div>
    </div>
</div>

controller: 控制器:

public function store(UploadRequest $request){
    $extension = Input::file('file')->getClientOriginalExtension();
    $filename = rand(11111111, 99999999). '.' . $extension;
    Input::file('file')->move(
      base_path().'/public/files/uploads/', $filename
    );
    $approved = $request['approved'];
    $fullPath = '/public/files/uploads/' . $filename;
    $upload = new Uploads(array(
        'name' => $request['name'],
        'format' => $extension,
        'path' => $fullPath,
        'approved' => $approved,
    ));
    $upload->save();
    $uploads = Uploads::orderBy('approved')->get();
    return view('uploadspanel.index', compact('uploads'));
}

Make sure you have the token included in your form, go to your page and inspect it, you should see something like this: 确保您的表单中包含令牌,然后转到页面进行检查,您应该会看到类似以下内容:

<input name="_token" type="hidden" value="Th4yqxNa3w3ooVAxRcSgvMug7ZEPA6BtaUw4qRck">

if you don't then add it in your blade like this: 如果不这样做,则将其添加到刀片服务器中,如下所示:

{{ Form::hidden("_token", csrf_token()) }}

Another issue you might have is in case you are submitting this form through an AJAX request, in that case, you would need to pass the token there too: 您可能遇到的另一个问题是,如果要通过AJAX请求提交此表单,在这种情况下,您也需要在其中传递令牌:

$.ajax({
    url  : '{{ route("your_route", optional_parameter) }}',
    type : "post",
    data : { '_token' : '{{ csrf_token() }}', 'var1' : var1 },
}).done(...)

It had to do with MAMP settings. 它与MAMP设置有关。 figured it out when i echo php_info(); 当我回声php_info()时就知道了;

then on line 6 or 7 followed the path to my php.ini then changed the inputs again with another editor, saved it. 然后在第6或7行上,遵循我的php.ini的路径,然后使用另一个编辑器再次更改输入,并将其保存。

retart MAMP server retart MAMP服务器

and done 并做了

This happens when your file which you are uploading is smaller than the max upload size but more than the POST_MAX_SIZE. 当您要上传的文件小于最大上传大小但大于POST_MAX_SIZE时,就会发生这种情况。 The input is truncated at the POST_MAX_SIZE which means that the csrf token is lost. 输入在POST_MAX_SIZE处被截断,这意味着csrf令牌丢失。

You can change these values in php.ini file. 您可以在php.ini文件中更改这些值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel 5-VerifyCsrfToken.php 67行中的TokenMismatchException - Laravel 5 - TokenMismatchException in VerifyCsrfToken.php line 67 VerifyCsrfToken.php 67行中的错误TokenMismatchException: - Error TokenMismatchException in VerifyCsrfToken.php line 67: PHP Laravel:VerifyCsrfToken.php 67行中的TokenMismatchException - PHP Laravel : TokenMismatchException in VerifyCsrfToken.php line 67 错误:laravel 5.2中VerifyCsrfToken.php第67行中的TokenMismatchException - Error: TokenMismatchException in VerifyCsrfToken.php line 67 in laravel 5.2 如何在Laravel 5.2中的VerifyCsrfToken.php 67行中修复TokenMismatchException - how to fix TokenMismatchException in VerifyCsrfToken.php line 67 in laravel 5.2 使用Route :: post()在VerifyCsrfToken.php第67行中的TokenMismatchException - TokenMismatchException in VerifyCsrfToken.php line 67 using Route::post() 使用ajax在laravel上的VerifyCsrfToken.php第67行中的TokenMismatchException - TokenMismatchException in VerifyCsrfToken.php line 67 on laravel using ajax Laravel 5.2-VerifyCsrfToken.php 67行中的TokenMismatchException: - Laravel 5.2 - TokenMismatchException in VerifyCsrfToken.php line 67: VerifyCsrfToken.php 67行中的TokenMismatchException:在Laravel 5.2中 - TokenMismatchException in VerifyCsrfToken.php line 67: in Laravel 5.2 如何解决VerifyCsrfToken.php第67行中的TokenMismatchException - How to solve TokenMismatchException in VerifyCsrfToken.php line 67
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM