Level 75
Use Storage::putFileAs()
https://laravel.com/docs/8.x/filesystem#specifying-a-file-name
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to save an image into storage and set up the controller
//Save image to disk
if($request->hasFile('image')) {
$image = $request->file('image');
$fileName = $image->getClientOriginalName();
Storage::put('blogImages/'.$fileName, $image);
$article->image_path = $fileName;
} else {
$article->image_path = 'holding.jpg';
}
And what its doing is creating a folder inside the blogImages folder and then a file inside that folder
Like so
/storage/app/blogImages/Screenshot 2020-12-26 at 08.57.37.png/c5gamVKUMJQBWjjEFAVdqUeYgsARXVlHQxF8AqzY.png
Im after just the image name inside the blogImages folder
Use Storage::putFileAs()
https://laravel.com/docs/8.x/filesystem#specifying-a-file-name
Please or to participate in this conversation.