0

I am using laravel 5.5. I have a form to upload image. Those images are storing into the storage/app folder. It is working fine. But when I try to show those images. Those are not showing. I have tried with those ways to print my images.

<img src="{{ asset('storage/1539872957.a-nice-place-to-picnic.jpg')}}" alt=""> <img class="user_avatar" src="{{ url('storage/app/1539872897.IMG_20180804_120323.jpg') }}"> <img class="user_avatar" src="<?php echo asset('storage/1539455504.prakruth-resort.jpg');?>">

Here I am giving image name as static name just for checking.

I have also done php artisan storage:link and a shortcut folder named 'storage' is created in the public folder. But still images are not showing.

Fokrule
  • 844
  • 2
  • 11
  • 30
  • They have to be in storage/app/public – Ivan Jelev Oct 20 '18 at 11:20
  • What is the source url formed when image is loaded in browser? – Kamal Paliwal Oct 20 '18 at 11:31
  • @IvanJelev even it is not allowing me to upload file outside storage/app folder. I have modified filesystem.php folder . But still those are storing to the storage/app folder. So I want to show them from this folder. – Fokrule Oct 20 '18 at 11:48
  • @KamalPaliwal Here is the output `` `` `` – Fokrule Oct 20 '18 at 11:49
  • When you accessing /storage/image.jpg your image have to be in laravelFolder/storage/app/public folder not in storage/app. Example: /www/laravel/storage/app/public/image1.jpg – Ivan Jelev Oct 20 '18 at 12:03
  • These images should be stored in storage/app/public folder after that symlinks will work properly. You can use Laravel File Storage (https://laravel.com/docs/5.7/filesystem), it will provide you functions to upload the images at proper location – Kamal Paliwal Oct 20 '18 at 12:11

1 Answers1

0

i think this Answer would help you.

you will have to create symlink from public/storage to storage/app/public first through this command

`php artisan storage:link`

Now any file in /storage/app/public can be accessed via a link like:

http://somedomain.com/storage/image.jpg

In your Controller use public driver like this:

 \Storage::disk('public')->put('file.png',file_get_contents($request->file->getRealPath()));

the above file.png would be stored in 'public/storage'.

now you can access the image file like this:

<img src="{{ asset('storage/file.png'); }}" />

Naveed Ali
  • 1,043
  • 7
  • 15