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 luckysheet
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误