0

I am using Laravel 5.4. I want to upload images with my blog. So I have uploaded images in storage/app/public/upload folder like this.

$request->file('file')->storeAs('upload', $fileName);

It is uploading images correctly. But my problem in displaying images in front end with blog.

I want to show image like below

<img src="{{asset('storage/app/public/upload/'.$imagename)}}" />  

It's add image path http://127.0.0.1:3000/storage/app/public/upload/man.png

But still image is not visible.

Fabien Sa
  • 9,135
  • 4
  • 37
  • 44
Shahadat Hossain
  • 947
  • 9
  • 24
  • Related - [How should I serve an image with Laravel?](https://stackoverflow.com/questions/36066144/how-should-i-serve-an-image-with-laravel) – shad0w_wa1k3r Feb 06 '17 at 07:00

2 Answers2

0

Try this

$path = storage_path();
<img src="{{asset($path .'app/public/upload/'.$imagename)}}" />

For more Info please read: https://laravel.com/docs/5.4/helpers#method-storage-path

Naincy
  • 2,953
  • 1
  • 12
  • 21
0

If you want to show the image directly, from URL, you need to specify the disk as public:
$request->file('file')->storeAs('upload', $fileName, 'public');
After you set the disk, you must create symlink from storage/app/public to public/storage folder via this command:
php artisan storage:link
And your asset url could look like this:
<img src="{{ asset('storage/upload/' . $fileName) }}" />

Ali Farhoudi
  • 5,350
  • 7
  • 26
  • 44