Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Yorkata's avatar

Custom path to store a file.

I created a command that fills .csv and stores it in /storage/app. I need to make a custom path to let's say my downloads directory. Tried like that:

$responce = Excel::store(new ClientProviderSport($compliance), $fileName, 'local', '/Downloads', \Maatwebsite\Excel\Excel::CSV);

My export file looks like this:

protected $invoices;

public function __construct(array $invoices)
{
    $this->invoices = $invoices;
}

public function array(): array
{
    return $this->invoices;
}
public function headings(): array
{
    return [
        'Client ID',
        'Client Name',
        'Number of Provider',
        'Number of Sports',
        'Sports'
    ];
}

And finally my filesystems.php looks like this:

'links' => [ public_path('Downloads') => storage_path(''), ],

Any and all help gratefully received.

0 likes
1 reply
Ashraam's avatar
Ashraam
Best Answer
Level 41

You probably should create a "new" disk with the custom path in the file config/filesystems.php and then specify the disk on the Store method

config/filesystems.php

'disks' => [
        'customDisk' => [
            'driver' => 'local',
            'root' => storage_path('app/Downloads'),
            'throw' => false,
        ],
],
Excel::store(new ClientProviderSport($compliance), 'name.xlsx', 'customDisk');

Please or to participate in this conversation.