Having created a new user via Voyager, the avatar was showing as a broken image. I uploaded a new image, but the image remained broken.
I checked with Console in Google Chrome and found 3 404 errors:
2017-06-19 10:53:50.159
http://localhost:8888/storage/users/June2017/ypKlbqbATDbpnYctZBFp.png
Failed to load resource: the server responded with a status of 404
(Not Found)
2017-06-19 10:53:50.256
http://localhost:8888/storage/users/June2017/ypKlbqbATDbpnYctZBFp.png
Failed to load resource: the server responded with a status of 404
(Not Found)
2017-06-19 10:53:50.473
http://localhost:8888/vendor/tcg/voyager/assets/images/bg.jpg Failed
to load resource: the server responded with a status of 404 (Not
Found) When I looked at the project, the paths for the 2 storage
errors are: http://localhost:8888/storage/app/public/users/ and:
http://localhost:8888/storage/app/public/users/June2017
While in Media, I'm seeing similar path problems when navigating the folders:
2017-06-19 11:38:22.248 %7B%7B%20selected_file.path%20%7D%7D:1 GET
http://localhost:8888/development/PhpstormProjects/Search4Venues/public/admin/%7B%7B%20selected_file.path%20%7D%7D
404 (Not Found)
Anticipating the question, in .env, I have: APP_URL=http://localhost:8888
Is this a configuration error?
EDIT
A colleague with more experience than me has been through Voyager and found some inconsistencies, which he's attempted to fix.
In app.php, we've had to change:
'url' => env('APP_URL', 'http://localhost:8888/development/PhpstormProjects/Search4Venues'),
... to:
'url' => env('APP_URL', 'http://localhost:8888'),
In filesystems.php, we've had to change:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
]
... to:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/development/PhpstormProjects/Search4Venues/public/storage',
'visibility' => 'public',
]
However, he discovered other problems in config/voyager.php:
'assets_path' => '/vendor/tcg/voyager/assets',
... where it too appears to be missing PhpstormProjects/Search4Venues from the path:
http://localhost:8888/vendor/tcg/voyager/assets/images/bg.jpg
At this stage, we have no idea what else could be wrong with Voyager.
Firs u need edit file .env:
APP_URL=http://localhost
to:
APP_URL=http://yout-site-url
After that u need edit the file fylesystem.php like this:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/public/storage',
'visibility' => 'public',
],
I was helped
Follow these steps:
1.Change APP_URL in the .env file to your website url.
For example:
APP_URL=http://localhost
to
APP_URL=http://127.0.0.1:8000
2.Create symbolic link by: (if not done yet)
php artisan storge:link
3.Restart your server (must. Otherwise chages will not be applied.)
this is common problem that even official site of voyager is mention about just read this page https://voyager-docs.devdojo.com/troubleshooting/using-https
in summery just open file filesystem.php in the folder config and delete this line of code 'url' => env('APP_URL').'/storage',
Update you .env file
APP_URL=http://localhost:8000
and then run
php artisan config:clear
last
restart your serve
this work for me.
This error sometimes usualy shown if we runing php artisan serve with default port like localhost:8000, but if you place laravel wit voyager in htdocs/www in your own server like xampp/mamp etc this error will gone,
So you can try :
Installing apache or stand alone webserver like wamp or mamp
place your project in htdoc/www folder, and don't forget to set .env app_url:localhost (or your domain without port)
change document root in apache config to your project folder
acces http://[your_domain]/[your_project]
done..
thank's
Updated .env file:
APP_URL=http://localhost:8000
Fixed issue
dont forget to restart the server
Updated .env file:
APP_URL=http://localhost/voyager
And Updated filesystems.php
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage/app/public',
'visibility' => 'public',
],
All you need to do is change in .env
APP_URL = http://localhost
to
APP_URL = http://<whatever your site is called>
And then move to the pic files to
public users
For some reason voyager stores them in
public users\users
At least it did for me
Just check what URL Voyager creates for the avatars and move them into the public folder with the same URL.
Worked for me at least
Change one line in .env file:
APP_URL = http://localhost
to
APP_URL = http://<your site url>
The command is used to remove the configuration cache file and created again.
php artisan config:cache
if you using laragon, change
'url' => env('APP_URL').'/storage'
to
'url' => env('APP_URL').'./storage'
Related
I am trying to upload the image to ./../public_html directory in laravel 7. However, the image always goes to lsapp/app/public/ directory.
In my Controller,
$storagePath = $request->donation_poster->storeAs('public/donation-poster', 'donation-poster-'.time().'.jpg');
config/filesystems.php
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
'links' => [
public_path('donation-poster') => storage_path('app\public\donation-poster'),
]
I think maybe the php artisan storage:link command isn't call, but i have no idea how to call using cpanel as it doesn't provide a terminal.
I know what is issue, my directory in public_html isn't linked with the one in public/storage. The command solve my issue,
ln -s <target> <link>
I am trying to show images from my symlink storage directory on my live server (shared) the scripts are working perfectly on my localhost but by the time i deployed it the image that was uploaded is not showing and returns page 404 error.
So i run the following command before deploying.
php artisan config:cache
php artisan route:cache
php artisan view:cache
and then run a symbolic link for the storage using a php script
symlink('/home/cpanelUsername/project_folder/storage/app/public', '/home/cpanelUsername/public_html/www.domain.com/storage');
My filesystem is set to public as below.
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
I have an image uploading and resizing function on my application and everything is storing just fine.
$request->file('profile_image')->storeAs('public/profile', $filenametostore);
$request->file('profile_image')->storeAs('public/profile/thumbnail', $smallThumbnail);
$ThumbNail = 'storage/profile/thumbnail/'.$smallThumbnail;
$this->createThumbnail($ThumbNail, 150, 93);
But the image is not loading or showing using below code. any idea why this is happening on live server and completely working fine on my local i also ensured that folder privilege have read and write.
asset('storage/profile/'.$member->profile_image)
I manage to solve it by changing FILESYSTEM_DRIVER=local to FILESYSTEM_DRIVER=public on my .env file
I've deployed my laravel project on my Shared Host, and try some my project features one of them is uploading an image. The image successfully uploaded into my Storage Folder, but when I try to view the image, my console give me 404 on that uploaded image URL like this URL :
http://member.gunabraham.com/storage/site/images/Site_Logo_1561217248.png
But in my local server, the uploaded image shows correctly on this URL :
http://localhost:8000/storage/site/images/Site_Logo_1561217645.png
This is my config/filesystems.php :
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
],
],
And my HTML file :
<a href="{{url('/home')}}" class="brand-logo amber-text center"><img src="{{asset('storage/site/images/'.$siteinfo->site_logo)}}" alt="" width="70" style="margin-top:15px;margin-bottom:15px;">
So what should I do on my laravel project which is deployed on Shared Hosting? Thanks for attention.
Solved by change my image source in HTML file from :
storage/site/images/
to :
storage/app/public/site/images/
Is this right choice? Or there're another solution to solve this problem?
You want to try link storage folder.
if /public/storage folder is already exists first go to public folder and delete exising storage folder then run this command
Are you tryed ?
try this command php artisan storage:link
if you don't have command pannel in shere hosting please create one route for run a comand
Route::get('/command',function(){
Artisan::call('storage:link');
});
Your files are being uploaded in the storage path and not the public path. You have mainly two options here:
1. Change your file-system to public path.
In your /config/filesystems.php
'public' => [
'driver' => 'local',
'root' => public_path('app/public/'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
Create a symlink and point the storage files via public folder. To do this you can run php artisan storage:link in your server console. If you don't have console access to server you can do this using a cron job.
Option 1 is better if you are using shared hosting with no console access.
I'm trying to achieve two things within my Laravel 5.8 project:
First of all, add the next variable on my .env file:
FILESYSTEM_DRIVER=public
And finally, modify my public disk url from this:
'url' => env('APP_URL').'/storage',
To this:
'url' => env('APP_URL').'/api/storage',
Either way, it doesn't work. What am I doing wrong? Is it the .env variable or I can't do such thing as modify the disk url?
Yes you can. To modify the default file system, set the FILESYSTEM_DRIVER in your .env file:
.env
FILESYSTEM_DRIVER=public
Then in your config/filesystems.php, to modify the url do this:
config/filesystems.php
'disks' => [
...
'public' => [
...
'url' => env('APP_URL').'/api/storage',
...
],
...
],
Do not forget to clear your config cache after doing this changes:
php artisan config:clear
I have a project in Laravel in which one of the sections uploads images to the server. Images are saved by using File storage and in the / storage/app/public folder.
In local it works correctly and the images look good, but when I upload the project to Heroku, the images are not seen. Even in Heroku if I run this command there are issues:
php artisan storage: link
Why is it that the images are not visible? I would not want to use AWS S3 for this. What could I have missed?
In your composer.json add:
"post-install-cmd": [
"ln -sr storage/app/public public/storage"
],
Heroku doesn't have file storage. So if you're going to use it for your servers you need to figure out another way to store files.
What I did that worked for me:
In your composer.json add:
"post-install-cmd": [ "ln -sr storage/app/public public/storage" ],( don't forget the comma , if you have any other line after the command above) But you should add the line above in scripts section.
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. This way it creates new shortcut folder storage (storage/app/public).
This works for me:
You can add to your command line in your Procfile.
worker: php artisan storage:link
After adding this please push your project to Heroku again.
Also, you can upload images to the public folder instead using of a storage folder, by this method you will not get problems like the above.
for that, you need to change the config in app/filesystem.php
Change from:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
Change into:
'public' => [
'driver' => 'local',
'root' => public_path(),
'url' => env('APP_URL').'/public',
'visibility' => 'public',
],
And you can store files so:
$pathToFile = Storage::disk('public')->put('uploads/', $file);
Now you can insert $pathToFile variable to the Database!