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,
public function store(Request $request)<br />
{<br />
$store = new Post;</p>
<p>//image<br />
if($request-&gt;hasFile('file')){<br />
$filename = $request-&gt;file-&gt;getClientOriginalName();<br />
$filename = $request-&gt;file('file')-&gt;storeAs('/images', $filename, 'public');<br />
$store-&gt;image = $filename;<br />
}...

2. The model

</p>
<p>class Post extends Model<br />
{</p>
<p>public function getImageAttribute($value)<br />
{<br />
return asset("storage/$value");<br />
}</p>
<p>}</p>
<p>

3. The view

&lt;img src="{{ $posts-&gt;image }}" alt="post image" width="50px" id="imediateImage"&gt;

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/lagjjail/public_html/kushtrim.net/wp-includes/functions.php on line 3729

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/lagjjail/public_html/kushtrim.net/wp-includes/functions.php on line 3729