I am trying to display a svg in my update page.
But when i try this:
<img src="{{ asset('storage/images'.$map->file_name) }}" />
(file extension is already included in the file_name)
I get an error 404 when i open inspect element.
I already linked the storage using: php artisan storage:link
The svg files are in this directory: storage/app/public/images and storage/app/images
The reason why i placed the svg files in two different is for debugging
I also made a new project to see if i did something wrong or it's the project.
I did the exact same in the current project but in there it did work.
Anyone know if there is something that i have to change or what ever?
Edit:
I already found a solution, i just had to remove the 'storage' from the asset
And i found out that laravel doesn't like it when i make a storage link and then move my project to a different pc/laptop
Related
Im really new to Vue.js and Quasar and am currently trying to build just a basic application.
In there i have a header which should display a logo on the top left using the following code in my MainLayout.Vue.
<q-layout view="hHh LpR fFf">
<q-header elevated class="bg-accent text-white">
<q-toolbar>
<q-toolbar-title>
<q-img src= "public/icons/favicon-16x16.png" style="width: 70px;">
</q-img>
Title
</q-toolbar-title>
</q-toolbar>
</q-header>
<q-page-container>
<router-view />
</q-page-container>
</q-layout>
It runs without an error, but the image is not displayed. At its position there is just a blank space. When i open up the JavaScript Console in my Browser,
Failed to load resource: the server responded with a status of 404 (Not Found)
The path is definitely right. Placing the image inside of the src/assets folder did not help as well.
I followed this tutorial, which lead me to the point im at now.
The only difference i can see is that the project in the tutorial uses the "static" folder for its image, however my project does not contain such "static" folder.
Googling i found that the "static" folder got turned into the "public" folder through some update.
But since i'm using the public folder for my code above, this seemingly either is not true or the issue is something else.
So how do i get my logo to be displayed top left in my header?
I have a Laravel Web Application deployed on AWS Beanstalk. Everything including the database works perfectly except for the image/file display. The logo, images, etc. aren't showing up. This is probably a file path problem. My images and files are stored in the "storage" directory. My path to the files are as such:
<img src="/storage/images/logo.png">
This works locally yet on the AWS server it doesn't. I tried all possible paths but still nothing worked. What am I doing wrong?
Try this one to retrieve the assets from the storage directory.
Storage::disk('local')->url('images/logo.png');
You can use it blade in the following format.
<img src="{{ Storage::disk('local')->url('images/logo.png') }}">
This will give the direct URL to /storage/images/logo.png
Also, you need to run the command:
$php artisan storage:link
Before running this command please check if the storage folder is already there or not inside the public folder if it's there then rename it to storage-bk and run the command.
I've SSH into the server and into the Laravel folder. I updated one of the html footer files but the changes aren't reflected on the website. I feel like I probably need to recompile something.
I tried deleting and re-creating the .env file (I backed it up first).
I've tried running the following commands:
php artisan clear-compiled
php artisan optimize
php artisan cache:clear
The only way I can seem to update the site is by updating the main.min.js file, located at /laravel/public/assets/js/main.min.js which is a terrible way to update the site.
How do I force Laravel to recreate this file or recompile the site based on changes I made to html template files within the site?
What am I missing here? I don't have any Laravel experience and am trying to update this site for a client.
edit:
I think I need to clarify a bit more...
The site appears to be rendered from this file: /public/assets/js/main.min.js
Most of the site's homepage, for example, is located in this js file. But the file is minified and therefore unwieldy to edit directly.
I am assuming (and I could be completely wrong here) that the file is generated from the html files located in the Laravel folder. To support this notion, I have found html files in other directories that correspond to the html located in the main.min.js file.
My assumption is that the previous developer would update the html files and then run something to compile the site into javascript files. But maybe this has nothing to do with Laravel, per se, and more to do with some frontend framework?
Try clearing the cached views...
php artisan view:clear
Laravel assets reside in
resources/assets/js
of your root directory you can have look their
if your file main.js is build using laravel mix have a on webpack.mix.js which compiles all your files you can get idea from that. make sure to run
npm run prod
if you change any file
Hope this helps?
I have a file in /storage/excel/exports/abc.xls and I want to create a download link to it, so I wrote:
<a href="{{asset('storage/excel/exports/'.$file)}}" download>{{$file}}</a>
But when I click on the link, it cannot find the file. then I looked at href in Inspect Element and the link was http://localhost/[my-project]/public/storage/excel/exports/abc.xls
And when I cleaned public/ using Inspect Element and changed href value, the link worked fine and it downloaded the file.
I have different ways to solve this issue but i'm sure none of them is best practice.
Whats the best way to create a link to a file in storage folder in laravel?
If you're on Laravel 5.5 you can use the Storage class. You can then use Storage::url($file) and it should get the proper URL for your file.
However, as per the docs:
Remember, if you are using the local driver, all files that should be publicly accessible should be placed in the storage/app/public directory. Furthermore, you should create a symbolic link at public/storage which points to the storage/app/public directory.
I have a Laravel project that I've mainly been working on it's back end, but now I copied the layouts from another project which has two images on the header. This is one of them:
<img class="img-logo" src="imagenes/temp_imgs/logo temporal.png">
The images on my old project are stored on public/imagenes/temp_imgs/, so I created those same folders on my new project and stored the images there. But when I run it I get the following error:
GET http://localhost:8000/competencias/imagenes/temp_imgs/logo%20temporal.png 404 (Not Found)
It seems as if it isn't looking for the images on my public folder but rather on the location of the view (competencias), the view is competencias/crear.blade.php
I don't remember much from the configuration on the old project, I only now I ran npm install on both at creation, so both have bootstrap and vue. But that's al I now, maybe you can help me see if a configuration file on the old project is making the image src point to the public folder, or figuring out what's generating the error.
EDIT:
If I paste one of the files from my old project to my new one the images are shown. If I rename one of the files from my new project and give it a name of a file from my old project the images are also shown! I hope this helps in figuring this thing out.
in laravel 5.4 you will not able to see image as your link
route will lock your every public folder
http://localhost:8000/competencias/imagenes/temp_imgs/logo%20temporal.png
just try to use like that
<img class="img-logo" src="{{ url('imagenes/temp_imgs/logo temporal.png') }}">
or
<img class="img-logo" src="{{ asset('imagenes/temp_imgs/logo temporal.png') }}">
You should use {{ asset('imagenes/temp_imgs/logo temporal.png') }}
For all assets use {{asset(....)}} to solve all problems that maybe appear for you
Hope help you