Контроллер:
Код: Выделить всё
$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]
Код: Выделить всё
[img]{{ asset([/img]
photo) }}" alt="Shape2503" />
Код: Выделить всё
Route::get('/storage/images/{path}', [ImageController::class, 'show'])->name('image.show');
Код: Выделить всё
public function show($path)
{
$path = storage_path('storage/images/'. $path);
return abort(401);
}
Подробнее здесь: https://stackoverflow.com/questions/784 ... el-browser