【发布时间】:2015-05-21 02:42:38
【问题描述】:
提交表单时,我不断收到“VerifyCsrfToken.php 第 46 行中的 TokenMismatchException”错误。
这是其中一种形式:
{!! Form::model($product, array('url' => 'product/'.$product->id, 'class' => 'form', 'method' => 'PATCH')) !!}
<div class="form-group">
{!! Form::textarea('note', $product->note,
array('class'=>'form-control', 'id'=>'product-note', 'placeholder'=>Lang::get('customtranslation.form_placeholder_note'), 'rows'=>3)) !!}
<br />
<span class="btn btn-link" id="remove-note" role="button"><i class="fa fa-times"></i> {{ Lang::get('customtranslation.button_txt_reset_note') }}</span>
</div>
<div class="form-group">
{!! Form::submit(Lang::get('customtranslation.button_txt_finish_edit_product'), array('class'=>'btn btn-success')) !!}
</div>
<div class="form-group">
<!-- Custom tags -->
{!! Form::label('additional-tags', Lang::get('customtranslation.form_edit_label_additional_tags')) !!}
{!! Form::text('additional-tags','', array('id'=>'additional-tags', 'data-role'=>'tagsinput')) !!}
</div>
{!! Form::close() !!}
名称为“_token”的输入元素按预期生成和设置。
奇怪的是,这只发生在 Internet Explorer (IE11) 中。 Chrome 和 FF 可以毫无问题地提交。
还有其他人有这个问题和可能的解决方案吗?
【问题讨论】:
-
调试您的应用程序并确保您在请求中获得了 _token 参数。
-
向我们展示该表单的代码
-
谢谢大家的回复。我已经用生成表单的代码更新了我的问题。该问题仅在 Internet Explorer 中出现。
-
您的域名中是否有下划线?喜欢local_host
-
@Chris 里面有一个下划线。我已将下划线更改为连字符,现在一切正常。感谢您的提示:)