dongqixuan3112 2016-01-26 06:01
浏览 54

Laravel帖子被检测为不允许和禁止的方法

I had this issue where I would get a method not allowed exception even though the route were set as Route::post and the server returned a 403 code and not detecting any form input. What should I do to get the method accepted properly as POST and can receive any form input?

Form

<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 &amp; 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>

The controller, simply just dump out the form data.

public function save()
{
var_dump(Input::all());
}

The route.

Route::post('/sell/details/save', 'SellDetailsController@save');

The textarea have an upload image feature, and is powered with tinymce + jboil.me plugin. The issue only occurs when the tinymce have an image uploaded on it, so when inputing a text only data inside tinymce editor, it would works normally.

So,

  1. Input without image, everything works fine.
  2. Input with image, method not allowed occurs and no form data in Input::all().
  3. Input with image, with Route::any instead of Route::post, forbidden returned and no form data.

How can I fix this and have both image and non image input works correctly?

Thanks.

  • 写回答

3条回答 默认 最新

  • douyoupingji7238 2016-01-26 06:17
    关注

    you have set the "Route:post" but you have set the method in form as GET. so the method is not allowing. Try making the route method and form method same.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看