Laravel Tutorials
- What is laravel
- Laravel Installation
- Directory Structure
- htaccess
- Remove public from url
- Artisan Command
- Laravel Configuration
- Routing Configuration
- Namespaces
- Request
- Response
- Controller
- Model
- User Authentication
- Multi User Authentication
- Database Seeding
- Database
- Database Query
- ORM
- One-to-One Relationship
- One-to-Many Relationship
- Many to Many Eloquent Relationship
- Has One Through
- Has Many Through
- Querying Relations
- Middleware
- Laravel Views
- Blade Views
- Print data on view page
- Get Site URL
- Get URL Segment
- Get images from Storage folder
- Clear cache
- Form Class not found
- Flash Message in laravel
- Redirections
- path
- CRUD Projerct
- CRUD in Laravel
- CRUD progran
- Laravel Validation
- Jquery Validation
- Cookie
- Session
- Email Send in laravel
- File uploading
- CSRF Protection
- Helper in Laravel
- Helper Functions
- Guzzle Http Client
- Paypal Payment Gatway Integration
- Cron Job in laravel
- Flash message
- path
- Errors Handling
- Date Format
- Date Format Validation
- Display Image on View Page
- Update User Status using toggle button
- Delete Multiple Records using Checkbox in Laravel?
- Confirmation Before Delete Record
- Delete image from storage
- Remove/Trim Empty & Whitespace From Input Requests
- Block IP Addresses from Accessing Website
- How to Disable New User Registration in Laravel
- Redirect HTTP To HTTPS Using Laravel Middleware
- CKEditor
- slug generate unique
- Prevent Browser's Back Button After Logout
- Datatable dunamically
- encrypt & Decript
- Download File
- Rest API
- Shopping Cart
- Shopping Cart Example
- Dynamic Category-Subcategory Menu
- Ajax Search
- Interview Question
- laravel Tutorilal link
- laravel Tutorilal
Important Links
How to get images from storage folder in laravel?
if you want to store images or files secure on his server. so anyone can not access your images of files directly using url. that's the reason laravel introduce storage folder for file upload.
Solution 1:-
if you want to show image using asset function than first of all you need to link your storage folder using following artisan command:
php artisan storage:link
php artisan storage:link
That creates a symlink from public/storage to storage/app/public for you and that's all there is to it. Now any file in /storage/app/public can be accessed via a link like:
http://somedomain.com/storage/image.jpg
php artisan storage:link
<img src="{{ asset('productsimages/'.$article->image) }}" alt="" title=""></a>
// here productsimages is a directory under storage folder.
Note :- You don't need to write storage folder name.
If your images are going to be public you should probably move the folder into public.
storage/app/public/images
Then you can print them with
asset('storage/images/'.$article->image)
.env file
File name : .env
FILE_PATH = storage/
File name : index.php
On Server
Storing images or files in storage folder under this route on your server
public_html/domain/storage/app/public/images
On localhost
Storing images or files in storage folder under this route on your localhost
htdocs/domain/storage/app/public/images
File name : index.php
Now suppose you want to print an image in the localhost blade file.
<img src="{{'Storage'.$post->featured_image)}}" alt="">
and this will symlink the path to the actual image stored path under storage folder - storage/app/public/images
But this is not the case on shared hosting. An image needs another path.
To overcome this problem, we will make a constant in the config/app.php
'file_path' => env('FILE_PATH', '/'),
and in the .env file, set its value according to the hosting (localhost or server)
# For localhost
FILE_PATH = storage/
# For server
FILE_PATH = domain/storage/app/public/
Now you access the image
<div style="background-image:url({{asset(config('app.file_path').$item->image)}});">
As simple as that...