Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VerifyCsrfToken.php第67行中出现错误TokenMismatchException:_Php_Laravel 5_Laravel 4_Laravel 5.2_Laravel 5.3 - Fatal编程技术网

VerifyCsrfToken.php第67行中出现错误TokenMismatchException:

VerifyCsrfToken.php第67行中出现错误TokenMismatchException:,php,laravel-5,laravel-4,laravel-5.2,laravel-5.3,Php,Laravel 5,Laravel 4,Laravel 5.2,Laravel 5.3,我是一个新的拉威尔。我试图在数据库中创建类别,但在VerifyCsrfToken.php第67行中遇到了令牌不匹配异常的问题:。遇到这个问题后,我尝试将{{csrf_field()}}添加到我的表单中,但它得到了相同的错误。请帮我解决这个问题。谢谢 查看表单 {!! Form::open(array('action' => ['Page_Admin@updatemaincate', $main_cate->id], 'method' => 'PUT', 'enctype' =&

我是一个新的拉威尔。我试图在数据库中创建类别,但在VerifyCsrfToken.php第67行中遇到了令牌不匹配异常的问题:。遇到这个问题后,我尝试将{{csrf_field()}}添加到我的表单中,但它得到了相同的错误。请帮我解决这个问题。谢谢

查看表单

{!! Form::open(array('action' => ['Page_Admin@updatemaincate', $main_cate->id], 'method' => 'PUT', 'enctype' => 'multipart/form-date')); !!}
    {{ csrf_field() }}
    <div class="modal-header" style="background:#3C8DBC;">
        <button type="button" class="close"  data-dismiss="modal">&times;</button>
        <h4 class="modal-title" style="color:#fff;">New Main-Category</h4>
    </div>
    <div class="modal-body">
        <div class="row">                               
            <div class="col-md-12">
                <div class="col-lg-12 col-md-12 col-sm-12">
                    <div class="form-group">
                        {!! Form::label('title', 'Title'); !!}
                        {!! Form::text('title', $value = $main_cate->title, $attributes = ['class' => 'form-control', 'name' => 'title']); !!}
                    </div>
                </div>
            </div> <!--end 12-->
        </div> <!--end row-->
    </div>
    <div class="modal-footer custom-default">
        {!! Form::submit('Edit', $attributes = ['class' => 'btn btn-default']) !!}
        <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
    </div>
{!! Form::close(); !!} 
路线

Route::get('/', 'Page_Admin@index');
Route::resource('admin', 'Page_Admin');
Route::get('maincategories', 'Page_Admin@maincategories');
Route::post('setmaincate', 'Page_Admin@setmaincate');

表单方法必须是“POST”,您可以使用{method_field('PUT')}在
app/Exceptions/Handler.php中设置方法

//instance of Token Mismatched
    if ($exception instanceof TokenMismatchException){
        //redirect to a form. Here is an example of how I handle mine
        return redirect($request->fullUrl())->with('csrf_error', $exception->getMessage());
    }
在顶部使用以下行:

use Illuminate\Session\TokenMismatchException;

您能否检查您的路线是否使用
web
中间件组?您可以运行php artisan route:list
并检查中间的列。您的路由应该使用
web
中间件组来进行会话。谢谢您的推荐,但我仍然遇到相同的问题谢谢您的推荐,但我仍然遇到相同的问题
use Illuminate\Session\TokenMismatchException;