1
votes

This is my route

Route::resource('admin/reports', 'ReportController');

This is controller function

public function store(Request $request)
{
    return "Thank you";
}

This is my html code

{!! Form::open([ 'url' => 'admin/reports/store', 'files' => true, 'enctype' => 'multipart/form-data', 'class' => 'dropzone', 'id' => 'reportfile' ]) !!}
    {!! csrf_field() !!}
    <div class="col-md-12">
        <h3 style="text-align : center">Select File</h3>
    </div>

    <div class="col-md-12" style="text-align: center; padding: 10px">
        <button type="submit" class="btn btn-primary">Upload Report</button>

    </div>
    {!! Form::close() !!}

When I submit the form, it show me MethodNotAllowedHttpException in RouteCollection.php line 218:

Any help is much appreciated. Thanks

1

1 Answers

3
votes

Your form action should just be admin/reports.

Currently it will assume you are trying to post to the route admin/reports/{id}. That endpoint is used with GET, PUT and DELETE.

Check the docs including a table giving you routes https://laravel.com/docs/5.1/controllers#restful-resource-controllers if I were you I'd use the route helper to generate your urls for you