I've downloaded a template from here.
I want to design pages like that in laravel blade pages, I put css and js files in public folder and link blade files to them, and it works.
But I can't handle images, there isn't a folder for images in this template and I don't know how to load them in my blade pages.
you can upload images on below path
storage/app/public/images
//this way you can use in your blade file
<img src = "{{ asset('/images/YOUR_IMAGE.png') }}" />
but you need to run one command
php artisan storage:link
it will create a symlink from public/storage to storage/app/public
please insert as below path and make link like that.
try this.
<div class="hidden-xs" style="width:200px; height:auto; margin-left:-10px;">
<img src="{{ asset('uploads/logos/myLogo.png') }}">
</div>
If not working... then check your App Url in /.env and restart your app server.
APP_URL=http://localhost
Happy coding~!:)
Related
I have followed the correctly marked answer in this question to save images in my app. I am having trouble displaying the images to blade file. I am using <img src="{{asset('/ProfileImages'.$p->profile_image)}}" alt="..."> ProfileImages is the storage folder with structure storage/app/ProfileImages. How do I display the images as the above line doesnot display?
Laravel storage filesystem is so unique. When you doing any upload it will upload in the storage/app/public directory. To make it accessible in public directory, things need to do is create symlink by run command:
php artisan storage:link
Or
<img src="{{ Storage::url($p->profile_image) }} " alt=""/>
StorageDocumentation
use Storage::url()
<img src="{{ Storage::url($p->profile_image) }}" alt="...">
ref link https://laravel.com/docs/8.x/filesystem#file-urls
By default when using {{asset()}} this will look inside your Public directory you should either consider storing photos inside your Public directory
Or take a look at the documentation about Laravel File System, here they explain how you can use storage directory and link it with your public directory
Laravel File System
Aslo you can use {{Storage::url()}} instead
I don't know how else to go about this issue. I've tried several suggestions I've seen online but to no avail. I'm working with laravel 7
My view is not loading any file from my public folder. Even images uploaded from the view to the directory is not loading back to view when called. I've symlink the storage and the public directory. However, I observed that my storage folder created was a shortcut but I expect that should be correct.
These are different ways I can remember I tried to call an image from the directory for example
<img src="{{ asset('storage/cover_images/img1.jpg') }}" alt="">
<img src="{{ URL::asset('storage/cover_images/img1.jpg') }}" alt="">
<img src="{{ Storage::url('cover_images/img1.jpg') }}" alt="">
<img src="/public/cover_images/img1.jpg">
Also note that all CDNs or images referenced externally are working properly.
When you symlink the storage public disc, a shortcut directory storage is created in your Laravel project's public folder. Now the asset() helper of Laravel isn't restricted to access storage files only, instead you can use this to access any file on the public path. By default, asset() helper uses the public directory as the root.
For example, if you have uploaded an image to public/images/first.png, then you can use asset('images/first.png') to generate the full URL for the image.
If you have properly symlinked the storage disk then you should be seeing files in the newly created public/storage directory. If it doesn't contain any files, you must have symlinked it improperly.
To ensure that asset() helper works fine, create a directory foo in your Laravel project's public folder and place some dummy file, i.e. test.png in that foo directory. Now using asset('foo/test.png'), you should be getting the full and valid URL to test.png file.
If it doesn't, maybe you have configured the asset helper's URL to some other destination using ASSET_URL in .env file.
I think you should not include storage or public , if you have symlink. You can call directly your asset like:
<img src="{{ asset('cover_images/img1.jpg') }}" alt="">
i always use this to go to the public folder:
src="{{ asset('img/pic.png') }}">
everything works perfect
but now is it not possible because i want to show the avatar picture and
something like this not works
<img src="../../public/uploads/avatars/{{$user->avatar}}">
so ive used this but it doesnt work i dont know how to go to the uploads folder
does anybody know the reason?
thank you!!!
Within the asset() helper, you have missed out the uploads/ folder.
So this should be src="{{ asset('uploads/avatars/' . $user->avatar) }}"
If your uploads folder is in the public folder, there is no need to use the asset() helper. You could just use the following:
<img src="/uploads/avatars/{{$user->avatar}}">
I host Laravel project on xampp server. but now I run the laravel project using php artisan serve. When I run the artisan server, the url is http://localhost:8000. but my xampp server is http://localhost. The url path is wrong. The images doesn't appear and javascript and jquery don't work on my project. how can i fix it?
use this way to url CSS and JS files path
<link rel="stylesheet" href="{{ URL::asset('css/app.css') }}">
and image path use
<img src="{{url('/images'}}">
//here you have to give public path ex: in your public folder has images then use like this
I m facing strange issue in laravel.
on my local serve it is not accessing this image
http://localhost:8000/img/logo.png
but I can acess this image
http://localhost:8000/img/profile.png
mover over it is not show in code as well any ideas.
Try
<img src="{{ url('img/yourimage.png') }}" alt="">
It will grab the image from your project public folder. It will look like yourwebsite.com/img/yourimage.png and in local server it will look like
http://localhost:8000/img/yourimage.png
2nd Solution:
Try
{{ Html::image('yourimage.png') }}
in laravel there is a inbuilt function url() which is used to ge the path from the public folder of your project. So to show image in your view you can use:
<img src="{{ url('img/yourimage.png') }}" alt="No image found">