我遇到了这个问题,即使路由设置为Route::post
并且服务器返回 403 代码并且没有检测到任何表单输入,我也会得到一个方法不允许异常。我应该怎么做才能将方法正确地接受为POST并且可以接收任何表格输入?
表格
<form data-role="none" method="post" data-ajax="false" action="http://www.example.com/sell/details/save">
<div class="form-row">
<div class="title">
Product Descriptions /<br>
Additional Pictures /<br>
Video
</div>
<div class="control">
<div id="mceu_4" class="mce-tinymce mce-container mce-panel" hidefocus="1" tabindex="-1" role="application" style="visibility: hidden; border-width: 1px;"><div id="mceu_4-body" class="mce-container-body mce-stack-layout"><div id="mceu_5" class="mce-toolbar-grp mce-container mce-panel mce-stack-layout-item mce-first" hidefocus="1" tabindex="-1" role="group"><div id="mceu_5-body" class="mce-container-body mce-stack-layout"><div id="mceu_6" class="mce-container mce-toolbar mce-stack-layout-item mce-first mce-last" role="toolbar"><div id="mceu_6-body" class="mce-container-body mce-flow-layout"><div id="mceu_7" class="mce-container mce-flow-layout-item mce-first mce-last mce-btn-group" role="group"><div id="mceu_7-body"><div id="mceu_0" class="mce-widget mce-btn mce-first" tabindex="-1" aria-labelledby="mceu_0" role="button" aria-label="Bold"><button role="presentation" type="button" tabindex="-1"><i class="mce-ico mce-i-bold"></i></button></div><div id="mceu_1" class="mce-widget mce-btn" tabindex="-1" aria-labelledby="mceu_1" role="button" aria-label="Bullet list"><button role="presentation" type="button" tabindex="-1"><i class="mce-ico mce-i-bullist"></i></button></div><div id="mceu_2" class="mce-widget mce-btn" tabindex="-1" aria-labelledby="mceu_2" role="button" aria-label="Insert/edit video"><button role="presentation" type="button" tabindex="-1"><i class="mce-ico mce-i-media"></i></button></div><div id="mceu_3" class="mce-widget mce-btn mce-last mce-btn-has-text" tabindex="-1" aria-labelledby="mceu_3" role="button" aria-label="Upload an image"><button role="presentation" type="button" tabindex="-1"><i class="mce-ico mce-i-image"></i>Upload</button></div></div></div></div></div></div></div><div id="mceu_8" class="mce-edit-area mce-container mce-panel mce-stack-layout-item" hidefocus="1" tabindex="-1" role="group" style="border-width: 1px 0px 0px;"><iframe id="text-description_ifr" frameborder="0" allowtransparency="true" title="Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help" src='javascript:""' style="width: 100%; height: 300px; display: block;"></iframe></div><div id="mceu_9" class="mce-statusbar mce-container mce-panel mce-stack-layout-item mce-last" hidefocus="1" tabindex="-1" role="group" style="border-width: 1px 0px 0px;"><div id="mceu_9-body" class="mce-container-body mce-flow-layout"><div id="mceu_10" class="mce-path mce-flow-layout-item mce-first"><div role="button" class="mce-path-item mce-last" data-index="0" tabindex="-1" id="mceu_10-0" aria-level="0">p</div></div><label id="mceu_12" class="mce-wordcount mce-widget mce-label mce-flow-layout-item">Words: 0</label><div id="mceu_11" class="mce-flow-layout-item mce-resizehandle mce-last"><i class="mce-ico mce-i-resize"></i></div></div></div></div></div><textarea class="input-gradient control-row" data-role="none" name="text-description" id="text-description" height="200" aria-hidden="true" style="display: none;"></textarea>
<div class="caption-bold caption">
Add in additional details of your products (i.e. functions, specifications,
etc.) and also pictures / video to make your sale item more attractive
</div>
</div>
</div>
<!-- .form-row -->
<div class="form-row">
<div class="title">Product Variations (if any)</div>
<div class="control" id="wrapper-variation">
<div class="control-row">
<div class="caption-bold caption">
<button type="button" class="btn btn-default ui-btn ui-shadow ui-corner-all" id="btn-add-more"><span class="fa fa-plus"></span> Add More
</button>
</div>
</div>
<input type="hidden" id="total_qty" value="10">
<div class="control-row">
<input type="text" class="input-gradient input-mobile" data-role="none" name="text-variation[0]" placeholder="Variation" value="">
<div class="caption caption-side">Qty</div>
<input type="text" class="promo input-gradient variation-qty" data-role="none" name="text-variation-qty[0]" placeholder="Qty" value="">
</div>
</div>
<div class="title"></div>
<div class="control">
<div class="control-row">
<div class="notice notice-check"></div>
<div class="notice notice-qty"></div>
</div>
</div>
</div>
<!-- .form-row -->
<div class="form-row">
<div class="title">Delivery Method</div>
<div class="control">
<div class="control-row">
<input id="check-delivery" data-role="none" type="checkbox" name="check-delivery" value="1" class="input-gradient">
<label for="check-delivery" id="label-ig">Normal Postage
</label>
<input type="text" class="promo input-gradient" data-role="none" name="postage-fee" id="postage-fee" style="margin-left:4px;width:150px;" value="" placeholder="Set Cost">
<div class="notice"></div>
</div>
<div class="control-row">
<label id="label-ig" for="qty-postage-fee">
Adjust Postage Fee by Incremental Qty of
</label>
<input type="text" class="promo input-gradient" data-role="none" name="qty-postage-fee" id="qty-postage-fee" placeholder="Qty" value="">
</div>
<div class="control-row">
<div>
<p>Example: Postage Fee $1</p>
<p>
By choosing an incremental qty of 5pcs, the cost of shipping
1-5pcs will be $1. Subsequent 5 pcs will cost
another $1, as such, the total of 10pcs would be $2.
</p>
</div>
</div>
<div class="control-row">
<input id="check-registered-mail" data-role="none" type="checkbox" name="check-registered-mail" value="1" class="input-gradient">
<label for="check-registered-mail" id="label-ig">Registered Mail</label>
<input type="text" class="promo input-gradient" data-role="none" name="mail-fee" id="mail-fee" style="margin-left:4px;width:150px;" value="" placeholder="Add. Cost">
<div class="notice"></div>
</div>
<div class="control-row">
<input id="check-self-col" data-role="none" type="checkbox" name="check-self-col" value="1" class="input-gradient">
<label for="check-self-col" id="label-ig">Self Collection</label>
<input type="text" class="promo input-gradient" data-role="none" name="self-location" id="self-location" style="margin-left:4px;width:250px;" value="" placeholder="Location">
<div class="notice"></div>
</div>
<div class="caption-bold caption">
Seller contact buyers directly to arrange pick-up at designated date,
time and location after the deal is confirmed.
</div>
</div>
</div>
<div class="form-row" style="text-align : center;">
<input type="submit" value="Save & Continue" class="btn btn-form-pro">
<!-- the following button is only for demo but the commented submit button above is the original one-->
<!--button type="button" class="btn btn-form-pro btn-pop" id="btn-save-details">Save & Continue
</button-->
</div>
</form>
控制器,只需转储表单数据。
public function save()
{
var_dump(Input::all());
}
路线。
Route::post('/sell/details/save', 'SellDetailsController@save');
textarea具有上传图片功能,并使用tinymce + jboil.me插件供电。 只有当tinymce上传了一个图像时才会出现这个问题,因此当在tinymce编辑器中输入仅文本数据时,它会正常工作。
所以,
Route::any
代替Route::post
输入图片,禁止返回,且没有表单数据。如何解决此问题并使图像和非图像输入都正常工作?
感谢。
答案 0 :(得分:0)
你已经设置了&#34;路线:帖子&#34;但是您已将方法设置为GET格式。 所以方法是不允许的。尝试使路由方法和表单方法相同。
答案 1 :(得分:-1)
由于TinyMCE将添加输入类型文件,您应该在表单中添加一个enctype属性:
<form [...] enctype="multipart/form-data">
如果表单标签是通过Laravel生成的,那么请使用:
{!! Form::open(array('url'=>'/sell/details/save','method'=>'POST', 'files'=>true)) !!}
答案 2 :(得分:-1)
在html表单中添加此行。
<input type="hidden" _token="{{ csrf_token }}" />