I have a form to upload multiple images. I have stored multiple image names into database while in Laravel, I'm using local storage storage/upload to upload my images.
Now I want to call them one by one. The solution I had in my mind didn't work. I need logic to call all images.
Controller
public function multiStepStore(Request $request)
{
if($request->hasFile('photos')) {
$files = $request->file('photos');
foreach ($files as $file) {
$filename = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
Storage::disk('local')->put($filename, File::get($file));
$filepath[] = $filename; // Store all Images into array
$getAllImages = collect($filepath)->implode(',');
}
}
}
Blade
<tr>
<td>Location</td>
<td>{{ $row->location}}</td>
</tr>
<tr>
<td>Images</td>
<td>
@foreach( (array) $row->img_path as $img)
<img src=" asset('storage/uploads/' .{{ $img }}">
@endforeach
</tr>
The output is just a broken image thumbnail. How can I get all images?
php artisan storage:link
then{{ asset('storage/uploads/' . $img) }}
/storage/uploads
, which is not apublic
directory. The public directory is/storage/app/public
. Nowphp artisan storage:link
will work