(InvalidArgumentException(code: 0): Disk [public] does not have a configured driver Voyager - php

I'm getting this error when I uploaded my project on a centos server
(InvalidArgumentException(code: 0): Disk [public] does not have a configured driver
Everything is correct in filesystem.php:
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'public' => [
'driver' => 'local',
'root' => public_path('storage'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
and in voyager.php :
'storage' => [
'disk' => 'public',
],
what should I do?

I have uploaded the same config files to the server, literally with no change and it worked...

Related

Facing 403 error while uploading images on my sites dashboard

I am having issue whenever I upload image from my site's admin dashboard.
It's always 403 error.
I have all my possible best but no way.
This is the code in the filesystem.php. Please help, what am I not doing correctly?
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
'private' => [
'driver' => 'local',
'root' => storage_path('app/private'),
],
//---
// Used for Admin -> Log
'storage' => [
'driver' => 'local',
'root' => storage_path(),
],
// Used for Admin -> Backup
'backups' => [
'driver' => 'local',
'root' => storage_path('backups'), // that's where your backups are stored by default: storage/backups
],
I think CSRF is missing in this form.

calling asset on production env didn't work Laravel 8 (shared hosting)

hello there I'm having trouble with calling my asset in the production environment this is how the structure of the folder
Laravel/
storage
...
public_html/
storage(a symlink that I created and working fine using, ln -sfn
domains/sites.com/new/storage/app/public/posted-images/ ../public_html/)
...
and this is how I call the asset :
<img src="{{ asset('storage/'.$posts->image) }}" alt="" class="img-fluid">
this is how my filesystem.php looks a like :
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
'links' => [
public_path('storage') => storage_path('app/public'),
],
and in .env I put :
FILESYSTEM_DRIVER = public
So I found the solution like this :
first I'm deleting the storage link that I created with ln -sfn domains/sites.com/new/storage/app/public/posted-images/ ../public_html/
then, in filesystem.php change :
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
to
'public' => [
'driver' => 'local',
'root' => 'storage',
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
after that, make a request to store function and it will create the storage folder in public_html. Your old file maybe not gonna appear there so(file before you change the root to 'storage'), you can copy the data that not there from storage folder in the domain.
And the way i call the asset is the same as above.

laravel5 create custom disk for uploading photo

I'm using laravel 5.6 and i wanted to create my custom disk for uploading images
and i received this error
InvalidArgumentException Driver [] is not supported.
this is how i save file in controller
$cover = $request->file('cover_image');
$extension = $cover->getClientOriginalExtension();
Storage::disk('test')->put($cover->getFilename().'.'.$extension, File::get($cover));
this is my config/filesystems.php
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'test' => [
'driver' => 'local',
'root' => storage_path(),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public/asghar'),
'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'),
],
the error occurred because my configuration was cached.
probably I accidentally used config:cache or sth similar.
the issue resolved by clearing the config cache using this command
php artisan config:clear

Laravel add two directories to local disk

Filesystem.php
How can i add another directory to local disk.
Currently only having the images directory
'disks' => [
'local' => [
'driver' => 'local',
'root' => public_path('images/'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
You can only specify the root of each disk defined in config/filesystems.php. You are free to define as many disks as needed however:
'images-subdir' => [
'driver' => 'local',
'root' => public_path('images/subdir'),
],
If I understand your question correct, you need:
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
]
Source: https://github.com/laravel/laravel/blob/master/config/filesystems.php

Laravel Driver error - Driver [] is not supported

Anyone else had this issue:
I set my filesystems.php config defualt from local to cloud (which is set to my s3) and I get this error with my storage code:
$path = $request->file('avatar')->store('avatars'); -> in my UserController
Error : Driver [] is not supported.
If I leave the filesystems config to stock and just run this code the image uploads to my s3 fine
$path = $request->file('avatar')->store('avatars', 's3'); -> in my UserController
shouldnt $path = $request->file('avatar')->store('avatars'); run to what ever the default is without passing the specific driver? I tried 'default' => 's3', and that gets the same error
CONFIG DRIVERS
'default' => 'local',
'cloud' => 's3',
'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_KEY'),
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'bucket' => env('AWS_BUCKET'),
],
],
I guess, that whether your example with manually typing a storage to the store() function works well, you can have a problem with storage config.
Could you, please, show your configuration file with storage types?

Categories