Storing images in the database is not recommended for performance reasons, Having said that, you need to check several things before you can do this.
First: verify that the MySQL server configuration allows you to upload packets of maximum 16MB, to do this you must configure the option max_allowed_packet=16M, the way to configure this depends on whether you use linux or windows, search the internet for a tutorial.
Second: the data type in the table must be stored as MEDIUM_BLOB so that you can upload images up to 16 MB maximum, the data types are:
BLOB allows maximum 64KB
MEDIUM_BLOB allows a maximum of 16MB
LONG_BLOB allows a maximum of 4GB
Blade Form:
<form action="{{ route('yourController.store') }}" method="POST" enctype="multipart/form-data">
@csrf
@method('POST')
<div class="row mb-4">
<p class="instructions">
Select the images or videos that you have of the model. It is necessary to upload at least one photo.
</p>
<div class="col-6">
<label class="form-label" for="pictures">Pictures</label>
<input type="file" name="pictures[]" multiple
class="form-control @error('pictures') is-invalid @enderror">
@error('pictures')
<div class="invalid-feedback">
{{ $message }}
</div>
@enderror
</div>
</div>
<div class="d-flex justify-content-end">
<button class="btn button btn-danger mx-2" type="reset">
Clean Form
</button>
<button class="btn button btn-success mx-2" type="submit">
Save
</button>
</div>
</form>
Controller:
public function store(Request $request)
{
$images = $request->file('pictures');
$allowedfileExtension = ['jpg','png','gif','jpeg','webp'];
foreach($images as $image)
{
$extension = $image->extension();
$hash = hash('md5', $image->get());
$filename = "$hash.$extension";
$filesize = $image->getSize() / 1024;
$originalName = $image->getClientOriginalName();
try
{
$account = new Account;
// .... etc. do something with the model
$account->logo= $image->get();
$account->save();
}
catch(\Illuminate\Database\QueryException $e)
{
// DEBUG IN CASE OF ERROR
dd($e);
}
}
return redirect()->back();
}