After Composer update laravel assets url not comes with public - php

in my Laravel 5.6 project i have a image URL
<img alt="بيتي فور" src="http://localhost/alhazim_working/public/assets/images/spinner.gif" data-src="http://localhost/alhazim_working/public/uploads/products/images/thumbnails/Petit four_2_3.png">
After run the composer update the url is not comes with public and image is not loading
<img alt="بيتي فور" src="http://localhost/alhazim_working/assets/images/spinner.gif" data-src="http://localhost/alhazim_working/uploads/products/images/thumbnails/Petit four_2_3.png">
similarly all the Css, Js and other images not working without public in url
also i run composer dump-autoload and php artisan cache:clear and generate key after composer update
and my folder structure is
also i run project without artisan commant

Laravel has a public folder which is the base folder for all requests. So if an image is in there you don't need to enter public in the url.
If your assets folder is in the public folder of laravel your url has to be like this:
http://localhost/assets/images/spinner.gif
instead of:
http://localhost/alhazim_working/public/assets/images/spinner.gif
Change it and your images will be displayed.

Related

Laravel CPanel - New Image to public folder not showing

I have uploaded my Laravel app to CPanel and it works completely fine. Then, I was making some changes to the Views by adding some new blade files. I also add new images to the public folder, where I put my previous images and it was working completely fine. But when I load the new page, the images are not showing, only the older image that I have uploaded before.
The HTML tag is the same as the already existing image but why it is not showing?
This is the HTML tag that I use in the blade:
<img src="{{ url('images/logo-cimahi.svg') }}"/>
I put the images in the public/images/ for the already existing images but the new images in the same path not showing.
Does my image broken or do I have to do something with PHP artisan command?
Try to clear all Laravel's cache, just run the following command:
$ php artisan optimize:clear
This will be an ouput:
Compiled views cleared!
Application cache cleared!
Route cache cleared!
Configuration cache cleared!
Compiled services and packages files removed!
Caches cleared successfully!

How to change Laravel url to localhost/website to get assets?

I transferred all the files in my laravel website to a folder called "project" except the public folder. I put all the files from the public folder to the main folder so I won't have to use "php artisan serve" every time I use the website locally like for example 192.168.1.100/website. The problem is that the assets and links became 192.168.1.100/dashboard, what I need is that 192.168.1.100/website/dashboard

Laravel 404 error while viewing image saved in public directory of laravel project

I created Laravel project and able to make it work to get json output as well. However image link in json is not working.
https://android.factory2homes.com/
json: https://android.factory2homes.com/index.php/api/products
image link:https://android.factory2homes.com/index.php/public/12142.jpg
i tried creating symlink and copied same image in storage folder as well, but not able to make it work.
The public folder in a Laravel project is basically the root folder that shows up on the website URL.
For security issues, you really don't want the users to have the ability to write anything directly on the public folder, because if you are not careful they could overwrite your php scripts and have them do whatever they want.
So generaly speaking you create a simlink inside the public folder to the storage folder that is outside the public directory. Laravel has even a built in artisan command to do that exactly which is:
php artisan storage:link
The URL to any image stored in that folder would be in your example:
https://android.factory2homes.com/storage/12142.jpg
You do not have to put any .php file, or public or anything else.
if the image is inside public then I don't think you need to give the url like index.php/public/someimage.jpg you can just do www.yousiteurl.com/someinage.jpg
I resolved issue by savings images to Public_html folder instead of public folder in Laravel app root folder. Public_html is the path that is visible to public, hence other solutions weren't working.

Cloned laravel project Dropzone storage link

I have set Laravel dropzone and it's working on my project.
I have cloned that project and trying to modify things but when I'm trying to upload files it's working and they are in the storage but when I want to see my files that I have uploaded I get
404
Sorry, the page you are looking for could not be found. error
This is my link when I click on the document
I'm using Laragon
EDIT:
I noticed that I have public >storage>storage
path:
public\storage\storage
And also a file named storage where I have a public file with an app file where inside I have another storage file
something like
path:
storage\app\public\storage\
Your link is looks like incorrect, http://mylocal.test/storage/storage/eOSuhkeabtKGuj4PRGePv0dxl8Fl0iQ3n7qLKvHs.pdf the storage path repeated on the url.
Can you try single storage path in the url?
http://mylocal.test/storage/eOSuhkeabtKGuj4PRGePv0dxl8Fl0iQ3n7qLKvHs.pdf
SOLUTION: when you clone your project delete public>storage and run
php artisan storage:link
to link it with your new path

Laravel Storage:Link not working for custom folder structure

My Laravel folder structure is
Laravel
|
|--site
|--files
Here, sites is my public folder. And rest of the folders go to files folder.
Now, when I run the command php artisan storage:link, it says
System cannot find the path specified
And obviously, the link is not working.
What am I missing here?
you have to update your helper functions
public_path()
storage_path()
according you your new directory structure
don't change the core may be you can create a new helper file and include in the composer.json.

Categories