Laravel app is not displaying images on server - laravel

Laravel app is not displaying images on server. It is giving symlink() cannot create error. because of this my slider images are not displaying.
I've tried to run several commands on server like:
cd /path/to/public_html/public/
ln -s ../storage/app/public/ ./storage
But it doesn't work. I want to remove error and show images.

Laravel has a special command made to create a simlink from your storage to the public folder:
php artisan storage:link

Related

Cannot display image in vue.js

I'm saving image in following path :
storage\app\public\img\user_image
and saving image url like this in database:
/img/user_image/285070719.png
trying to display image like this:
<img :src="'../app/public'+profile.image">
but the image does not display, Any solution to resolve this issue is highly appreciated.
Have you create a storage link? php artisan storage:link https://laravel.com/docs/8.x/filesystem#the-public-disk
Then you should be able to use the uri like /storgae/img/user_image/285070719.png
Make sure that you created the symlink from public/storage to storage/app/public with php artisan storage:link, after that make sure that the generated URL is correct.
The following URL should be generated:
http://localhost:8000/storage/img/user_image/285070719.png
Something like the following should work for you:
<img :src="'/storage'+profile.image">
From the docs:
The public disk is intended for files that are going to be publicly accessible. By default, the public disk uses the local driver and stores these files in storage/app/public. To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public. To create the symbolic link, you may use the storage:link Artisan command: php artisan storage:link

laravel symlinks on a window machine

Using a windows server, I have a laravel installation.
I have a storage folder that I have created on 'root/storage'
When I save images from the website, the images are stored in this folder.
I use this to save the files:
Storage::disk('local')->put('course_badges/'.$pre_string . $request->file('badge')->getClientOriginalName(), File::get($request->file('badge')));
When I try to reference the file like so 'https://app.com/storage/file_name.jpg', laravel gives me a 'Sorry, the page you are looking for could not be found.' error.
However is I copy the files to '/public/storage/'
The image is then referenced correctly.
I have run the: php artisan symlink function.
I have tried to run ln -s ../storage/ command in powershell, but windows tells me that ln is not recognized.
What I am trying to achieve is to have my files saved in the root/storage folder (and sub folders)
and to reference them using https:app.nam/storage/file
I had simmilar issue
as u mentioned file is stored in root/storage means problem with symlink between root/storage to public/storage to fix this
remove storage folder from public dir
Note:- keep backup first
then run php artisan storage:link
it should work

laravel 6.9 localhost keep loading than Not found

I download a fresh laravel project from someone for testing.
After setting up and running using php artisan serve, the locahost (http://localhost:8000/) keep loading slowly then It shows message 404 not found.
I have tried to solve using command line php artisan serve --port=1010 and run http://localhost:1010/ on broswer but It didn't work.
And I also used php -S localhost:8000 -t public or php -S 127.0.0.1:8000 -t public after run localhost:8000 on broswer but it still didn't work.
any idea?
Check once there is storage/framework/cache/data and storage/framework/sessions directory created or not, if those doesn't exist then create manually.

Laravel did not serve but displays directories and folders

I am using Laravel 5.8. I just created a Laravel Application. When I wanted to serve it I used localhost:8888/smart-lms . It did not load the default page, but instead it displays folders and directories as shown below. What do I do please?
port: 8888
project: smart-lms
In your project directory, run php artisan serve in your command line

Creating symlink setting up Laravel 5.6 on a remote server

I'm setting up a Laravel 5.6 site in a remote shared hosting server.
I'm failing at creating the storage symlink. I'm executing a file with the following line (as Laravel documentation and other tutorials instruct):
symlink('/home/nataliag/laravel/storage/app/public', '/home/nataliag/public_html/storage');
this creates a symlink, but instead of getting my images with mydomain.com/img/..., i have to go mydomain.com/storage/img/....
what link the php artisan storage:link creates? because that works in local, and all my links are created following that structure

Resources