0

I saved my images in storage folder successfully. my image path is below in storage folder "storage/app/". Now i want to show image in views and also i want to download images there.
For showing image i write below code in views but image not show. Please help me why image not show....

 <img src="<?php echo asset('storage/'.$row->file_name.'/'); ?>"  class="img-responsive" />

below my controller function.

public function store(Request $request)
        {
            $model = new FilesModel();

            if($request->file('file_name'))
            {
               $filename = $request->file_name;
               $files  = $filename->getClientOriginalName();
              Storage::disk('local')->put($files ,'centent');
              $model->file_name = $files ;
            }
           $model->save();
            return redirect('files');
        }
alex
  • 121
  • 1
  • 7
  • Duplicate of http://stackoverflow.com/questions/30191330/laravel-5-how-to-access-image-uploaded-in-storage-within-view – Dan H Jan 30 '17 at 09:27
  • 2
    Possible duplicate of [Laravel 5 - How to access image uploaded in storage within View?](http://stackoverflow.com/questions/30191330/laravel-5-how-to-access-image-uploaded-in-storage-within-view) – Dan H Jan 30 '17 at 09:27

1 Answers1

0

You are using asset() helper function to retrieve a file saved in the storage directory. Normally asset() function points to your public directory, therefore in this case it is looking for your file in public/storage/app/file.ext. I suggest you change from asset() to storage_path() and then you can access the image like:

<img src="<?php echo storage_path('app/'.$row->file_name.'/'); ?>"  class="img-responsive" />
xhulio
  • 1,093
  • 1
  • 13
  • 32
  • can you try with inspect element and tell me what the img src looks like? – xhulio Jan 30 '17 at 10:32
  • continuously three days i search solution but still my problem not solve kindly tell me whats the problem – alex Jan 30 '17 at 10:51