0

I'm new to laravel. When I try to generate a form, the problem occurred. My route

Route::get('post/add', "Post1Controller@add");
Route::post('post/store', "Post1Controller@store");

My Post1Controller

 function add()
    {
        return view('post/create');
    }
  function store(Request $request)
    {
        echo "Had file";}

My form

 {!! Form::open(['url'=> 'post/store','method'=>'POST',  'files'=> true]) !!}

        <div class="form-group">
            {!! Form::file('image', ['class' => 'form-control'])!!}


        </div>
        <div class="form-group">
            {!! Form::text('title', '', ['class' => 'form-control', 'placeholder' => 'Title in here'])!!}

        </div>
        <div class="form-group">
            {!!form::textarea('content','',['class'=> 'form-control', 'placeholder'=> 'Text in here'])!!}

        </div>
        <div class="form-group">
            {!! Form::submit('Add', ['name'=>'sm-add', 'class' => 'btn btn-danger'])!!}

        </div>


        {!! Form::close() !!}`enter code here`

My issue: The GET method is not supported for this route. Supported methods: POST. Thank you for your support.

  • Open your browser's Developer console, and watch the Network tab. Make sure when you submit the form that it's submitting via POST, and not attempting a redirect, such as HTTP -> HTTPS – aynber Jan 04 '22 at 13:32
  • dont open in your browser the URL `http(s)://..../post/store` that will not work, go to the URL `http(s)://..../post/add` – N69S Jan 04 '22 at 13:33
  • tks anyway but the problem is still there. – NameIsQuang Jan 04 '22 at 13:55
  • did you try to check & test it with vanilla code? add
    as HTML tag and then test :) also i assume you forgot to include csrf ;)
    – Mohammad H. Jan 04 '22 at 15:04
  • Did you try `php artisan route:clear` and after that `php artisan optimize`? – kingbeencent Jan 07 '22 at 02:06

0 Answers0