How to access images inside public folder in laravel

+1 vote

Hii,

How can I access the images stored inside public/images folder without the use of Laravel's own functions like assets()?

I just want to get the direct URL of the images stored in images folder.

Eg:

localhost/webapp/images/fool.png

When requesting the link i should get the direct image.

Thanxx in advanced!!

Apr 3, 2020 in Laravel by kartik
• 37,510 points
103,495 views

I suggest you to try something like that

Just put your Images in Public Directory (public/images_folder).

Let's suppose I stored images in public/images/Cloudways_logo.jpg.

View

<img src="{{url('/images/myimage.jpg')}}" alt="Image"/>

4 answers to this question.

0 votes

Hii,

Just put your Images in Public Directory (public/...folder or direct images).
Public directory is by default rendered by laravel application.
Let's suppose I stored images in public/images/myimage.jpg.
Then in your HTML view, page like: (image.blade.php)

<img src="{{url('/images/myimage.jpg')}}" alt="Image"/>

Thank YOu!!

answered Apr 3, 2020 by Niroj
• 82,820 points
Thank you so much....u nailed it...good work
0 votes

You simply need to use the asset helper function in Laravel. (The url helper can also be used in this manner)

<img src="{{ asset('images/arrow.gif') }}" />

For the absolute path, you use public_path instead.

<p>Absolute path: {{ public_path('images/arrow.gif') }}</p>

If you are providing the URL to a public image from a controller (backend) you can use asset as well, or secure_asset if you want HTTPS. eg:

$url = asset('images/arrow.gif'); # http://example.com/assets/images/arrow.gif
$secure_url = secure_asset('images/arrow.gif'); # https://example.com/assets/images/arrow.gif

return $secure_url;

Lastly, if you want to go directly to the image on a given route you can redirect to it:

return \Redirect::to($secure_url);

More Laravel helper functions can be found here

answered Aug 28, 2020 by Dsouza
• 150 points
0 votes

This is also the method used by Envoyer, a deployment manager built by Taylor Otwell, the developer of Laravel. To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public . Then in any view, you can access your image through URL helper like this

answered Dec 14, 2020 by Gitika
• 65,890 points
0 votes

If you are inside a blade template

{{ URL::to('/') }}/images/stackoverflow.png

answered Dec 14, 2020 by Rajiv
• 8,910 points
How to access images inside public folder in laravel  | Edureka Community
[url=http://www.g46pq15u13cm55m176i1cicj3el2xf50s.org/]uivoozlsx[/url]
ivoozlsx http://www.g46pq15u13cm55m176i1cicj3el2xf50s.org/
<a href="http://www.g46pq15u13cm55m176i1cicj3el2xf50s.org/">aivoozlsx</a>
How to access images inside public folder in laravel  | Edureka Community
qpsoxfodwj http://www.ge3qq3g7h9y37s556g0b584zjox7m23ns.org/
<a href="http://www.ge3qq3g7h9y37s556g0b584zjox7m23ns.org/">aqpsoxfodwj</a>
[url=http://www.ge3qq3g7h9y37s556g0b584zjox7m23ns.org/]uqpsoxfodwj[/url]
How to access images inside public folder in laravel  | Edureka Community
[url=http://www.gfl1kxpaa3u53h969yz1496y4m98ma90s.org/]uowfrctgth[/url]
owfrctgth http://www.gfl1kxpaa3u53h969yz1496y4m98ma90s.org/
<a href="http://www.gfl1kxpaa3u53h969yz1496y4m98ma90s.org/">aowfrctgth</a>

Related Questions In Laravel

0 votes
1 answer

How to pass data through URL and access through controller in Laravel?

Hello, You can  first refer how to  Create controller through ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,820 points
10,285 views
+1 vote
1 answer

How to get public directory in laravel?

Hello @kartik, Use public_path() For reference: // Path to the project's ...READ MORE

answered Aug 10, 2020 in Laravel by Niroj
• 82,820 points
20,760 views
0 votes
1 answer

How to call a controller function inside a view in laravel 5

Hello @kartik, Just try this in your view ...READ MORE

answered Sep 25, 2020 in Laravel by Niroj
• 82,820 points
6,840 views
0 votes
1 answer

How to Get the Current URL Inside @if Statement in Laravel?

Hello @kartik, You can use: Request::url() to obtain the current ...READ MORE

answered Nov 11, 2020 in Laravel by Niroj
• 82,820 points
2,546 views
0 votes
1 answer

Why it is necessary to refresh CSRF token per form request?

Hello, Generating a new CSRF token for each ...READ MORE

answered Mar 19, 2020 in Laravel by Niroj
• 82,820 points
3,223 views
0 votes
1 answer

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,820 points
1,936 views
0 votes
1 answer

Connection with MySQL server using PHP. How can we do that?

Hey @kartik, You have to provide MySQL hostname, ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,820 points
542 views
0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,820 points
1,838 views
0 votes
1 answer

How to upload files in Laravel directly into public folder?

Hello @kartik, You can create a new storage ...READ MORE

answered Sep 28, 2020 in Laravel by Niroj
• 82,820 points
8,228 views
0 votes
2 answers

How to delete file from public folder in laravel?

I just want to add @niroj answer  Use ...READ MORE

answered Nov 5, 2020 in Laravel by Helloworld
• 140 points
18,799 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP