dpm91915 2014-12-13 05:34
浏览 161

异常'Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException'上传大文件laravel

In a view in laravel i have a form that upload a file:

<form id="file-submit" enctype="multipart/form-data" method="post" action="store">
            {{ Form::token() }}
            <input id="filename" name="filename" type="file" />
            <input type="submit" value="Upload file" id="file-save" class="btn btn-create" />
        </form>

In the route file i have:

Route::post('/store', 'MyController@upload');

There in the method, i process the file data.

This works in my local server, i upload it in production, so, this works when i upload files around 5kb, but if i try to upload a large file, around 4MB it breaks with this error:

production.ERROR: exception 'Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException' in <laravel_instance>/protected/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php:210

I have the same memory settings in php.ini file (memory_limit, post_max_size, excecution_time, max_input_time, upload_max_size)

Thanks

  • 写回答

1条回答 默认 最新

  • dousa2794 2014-12-13 06:07
    关注

    I suspect that it has something to do with you manually creating the form.

    Try doing it like this:

    Route:

    Route::post('/store', [
        'as' => 'store',
        'uses' => 'MyController@upload'
    ]);
    

    Form:

    {{Form::open([
        'id' => 'file-submit',
        'enctype' => 'multipart/form-data',
        'action' => 'store'
    ])}}
    
    {{Form::file('filename')}}
    
    {{Form::submit()}}
    
    {{Form::close()}}
    
    评论

报告相同问题?

悬赏问题

  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程