Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

store image in storage laravel

/*
|=================================================================
| 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');
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #store #image #storage #laravel
ADD COMMENT
Topic
Name
3+6 =