Reputation: 55
home.blade.php file '''
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Dashboard') }}</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
{{ __('You are logged in!') }}
</div>
<div class="card-body">
@csrf
<form action="/upload" method="post">
<input type="file" name="image">
<input type="submit" name="upload">
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
'''
My routes '''
Route::post('/upload',function (){
return('Halu');
});
I don't know where the error is help out as I am a beginner on laravel 8. The route is defined with the function and I don't know where the get or post goes wrong
Upvotes: 0
Views: 168
Reputation: 367
you try to upload a file you have to set enctype="multipart/form-data"
to your form
it should look like this
<form action="{{ url('/upload')}}" method="post" enctype="multipart/form-data">
@csrf
</form>
this may solve your issue
Upvotes: 1
Reputation: 15296
Pass the url in action attribute. and pass @csrf
token inside the form.
<form action="{{ url('/upload')}}" method="post">
@csrf
</form>
Upvotes: 1