I’m looking for a way to view the images contained in a private folder in storage: here is the asset storage/app/private/images/nomefile.jpg my problem is that I would like to view the images only via asset blade and not view them via the full path of the URL, this is because I would like them not to be public but only viewable in the app after authentication, so via asset() there is a way. I’ve tried them all but I can’t, here’s the code:
Controller :
$request->validate([
'image' => 'required|image|mimes:jpg,jpeg,png|max:8000'
]);
$imageName = time() . '.' . $request->image->getClientOriginalExtension();
$request->image->store('images', 'private');
$imageName = $request->file('image')->hashName();
$safeImageName = htmlspecialchars($imageName, ENT_QUOTES, 'UTF-8');
DB::table('aree')->where('id_area', $id)->update(['photo' => $safeImageName]
Blade :
<img src="{{ asset('storage/images/' . $item->photo) }}" alt="Shape2503" />
web.php for block url
Route::get('/storage/images/{path}', [ImageController::class, 'show'])->name('image.show');
controller for block url
public function show($path)
{
$path = storage_path('storage/images/'. $path);
return abort(401);
}
help me please