/*
|=================================================================
| How to store files in laravel -- (Public , Storage , S3)
|=================================================================
*/
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
$image = $request->image;
$imageName = time() . '.' . $image->extension();
// 1) Store in Storage folder -- (Path => storage/app/images/file.png)
$image->storeAs('images', $imageName);
// 2) Store in Public Folder -- (Path => public/images/file.png)
$image->move(public_path('images'), $imageName);
// 3) Store in AMAZON S3 -- (Path => public/images/file.png)
$image->storeAs('images', $imageName, 's3');
$fileName = $file->storePublicly('images/media', [
'disk' => 's3'
]);
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
$imageName = time() . '.' . $request->image->extension();
Store in Storage folder
$request->image->storeAs('images', $imageName);
// storage/app/images/file.png
Store in Public Folder
$request->image->move(public_path('images'), $imageName);
// public/images/file.png
Store in S3
$request->image->storeAs('images', $imageName, 's3');
// public/images/file.png
<img src="{{ url('storage/yourforlder/yourimage.jpg') }}" alt="" title="" />