store image in folder and get them to the frontend

In this Article we will see how we are able to add images or other files to our projects folder and show them to the frontend.

  1. The Controller,

[code]public function store(Request $request)
$store = new Post;

$filename = $request->file->getClientOriginalName();
$filename = $request->file(‘file’)->storeAs(‘/images’, $filename, ‘public’);
$store->image = $filename;

2. The model


class Post extends Model

public function getImageAttribute($value)
return asset(“storage/$value”);



3. The view

[code]<img src=”{{ $posts->image }}” alt=”post image” width=”50px” id=”imediateImage”>[/code]


Leave a Reply

Your email address will not be published.