Search code examples
phpstoragelaravel-7

Laravel 7 store file in absolute path


I have a vps that use custom folder to save a file, and they put the folder at the root of the system /storage but the website folder is at /var/www/html/mywebsite . Is there any way to configure laravel to store uploaded files to /storage folder?


Solution

  • I want to say that using the __DIR__ predefined constant will help:

    __DIR__ . "/../../../storage/<something>"
    

    Edit:

    The route to go would be to create a new disk in your file system config.

    'disks' => [
        'custom_folder_1' => [
            'driver' => 'custom',
            'root'   => __DIR__ . '/../../../storage/path/to/your/new/storage/folder',
        ],
    ]