Laravel - Configure storage in a different directory where is the project

1k views Asked by At

I have a project located in this path /var/www/html/backend/api_cars

I have a storage configured to hang certain files in the "public" folder, but now I would need to upload files (for this I use dropzone js), with the particularity that when they are uploaded must be copied to a directory that is not within the project,

Its path is /var/www/html/images/catalog/cars

My question is how can I do it with laravel, I have tried to configure a "storage" of type "folder" but it gives me an error.

In the file config/filesystems.php I have created this

   'public' => [
    'driver' => 'images-cars',
    'root' => storage_path('/var/www/html/images/catalog/cars'),
    'url' => env('APP_URL').'/catalog-cars',
    'visibility' => 'public',
],

It had occurred o create a "Symbolic link" within a project folder to the other folder, but I don't know if it would work.

Thanks in advance.

1

There are 1 answers

0
SEYED BABAK ASHRAFI On BEST ANSWER

You can direct to your desired folder by using public_path function like as below:

'public' => [
    'driver' => 'public',
    'root' => public_path('../../images/catalog/cars'),
    'visibility' => 'public',
],