I'm kinda new to Laravel and I made a form for my page which users can add new image, and this form is in create.blade.php:
<form action="/p" enctype="multipart/form-data" method="post">
@csrf
<div class="row">
<div class="col-8 offset-2">
<div class="row">
<h1>Add New Post</h1>
</div>
<div class="form-group row">
<label for="caption" class="col-md-4 col-form-label">Post Caption</label>
<input id="caption"
type="text"
class="form-control @error('caption') is-invalid @enderror"
name="caption"
value="{{ old('caption') }}"
autocomplete="caption" autofocus>
@error('caption')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<div class="row">
<label for="image" class="col-md-4 col-form-label">Post Image</label>
<input type="file" class="form-control-file" id="image" name="image">
@error('image')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
<div class="row pt-4">
<button class="btn btn-primary">Add New Post</button>
</div>
</div>
</div>
And this is the web.php (routes) file:
Route::get('/p/create','PostsController@create');
Route::get('/p','PostsController@store');
Route::get('/profile/{user}', 'ProfilesController@index')->name('profile.show');
As you can see it refers to PostController.php which is this:
class PostsController extends Controller
{
public function create()
{
return view('posts.create');
}
public function store()
{
dd(request()->all());
}
}
Also I do the command php artisan route:list and this is it:
So what is going wrong here? I've searched a lot but couldn't find anything useful. So if you know how to solve this, please let me know.
Thanks in advance
