GET imageRoute 404 (Not Found) on Laravel - laravel

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

Related

Quasar / Vue.js Image in header not showing

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?

Trying to introduce CAS in a website uploaded to a shared host

I'm trying to make my Laravel project work on a shared host as well as it does in localhost but I don't get how to do that... I uploaded my project following the steps of this tutorial: https://www.youtube.com/watch?v=_0ixeeACvZE and it worked.
I think the problem is with the folders structure because following that video I change my public folder to the public_html folder, so I lose the first one. Two problems appear here: I can't upload an image because in localhost I used to use the path public/images to do that and now I've tried to change the path but it doesn't work... However I don't wanna focus on this, the biggest problem appears when I try to add my login structure throgh CAS...
Once more, it works in localhost but in the shared host, from the moment I add these lines of code:
#if (!Cas::isAuthenticated())
#include('login')
#else
#include('partials.nav')
#yield('content')
#endif
The system gets lost in the !Cas::isAuthenticated() method and this is what it shows:
Error
To install CAS in my site I used this https://codedog.net/2017/12/19/laravel-and-cas/ and as I said, it worked locally...
Please I really need this... any help is huge. If you need more details please just let me know.
Thank for your time

Laravel 8, get asset not found (404)

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

laravel not picking file through asset()

In my laravel project i am trying to get js file though asset('js/app.js') which is inside public folder. it is working fine on localhost but on server it is not picking file. It is working on another server. I think there is any issue with htaccess file.
I try to use url() and URL::asset() but not working. I checked source of page link is perfect but still fail to pick file
I want to access that js file.
The question has been answered in the comments, and was solved with this code:
asset('public/js/app.js')

in laravel how to display image in home.blade.php or any page, from out side of laravel project (out side of root folder)

in laravel (localhost and online hosting )how to display image in home.blade.php or any page, from out side of laravel project (out side of root folder)
i tried this two code but not work.
<div><img src="file:///C:/USER/User_Profile_Image/{{ Auth::user()->image }}" alt="profile"/></div>
<div><img src="file:///C:/USER/User_Profile_Image/default.jpeg" alt="profile"/></div>
Before I give you an answer I just wanted to mention, I wouldnt suggest accessing anything outside of your project directory, this can cause many problems when it comes to relocation of the project or if a file structure changes.
Possible Solution (Not Recommended)
If you had reasoning to have to access something outside of the laravel directory you can just use the '..' which means going into the parent folder.
Example
<img src="../../../User_Profile_Image/default.jpeg" alt="profile"/>
Other than that you could look into some straight PHP things around the documentation.
Alternatives ()
If you are trying to store and access images in a public place you can use the public folder in laravel. Everything in this folder can be accessed by the public and is made to store publicly accessible things in such as profile pictures.
Public Example
use Illuminate\Support\Facades\Storage;
Storage::put('file.jpg', $contents);
<img src="/file.jpg" alt="profile"/>
Hope this answered your question, good luck!

Resources