Answer the question
In order to leave comments, you need to log in
How to upload multiple laravel images?
How to implement multiloading of images?
Now I upload one image to the server and save its path to the database:
<input type="file" name="image" >
В контроллере:
$img = $request->file('image')->store('publick_img','public'); //загружаю на сервер
$news_body->image = $img; // сохраняю путь
Answer the question
In order to leave comments, you need to log in
<input type="file" name="images[]" multiple>
And now in the controller $request->file('images') will be an array that will need to be iterated.
On something like this pseudo code
$images = [];
if ($request->hasFile('images')) {
foreach($request->file('images') as $key => $image){
$images[] = $image->store(uniqid(), 'public');
}
$news_body->image = json_encode($images);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question