Skip to content
Advertisement

Laravel: How to store Excel File in a given path?

I have a function which is converting my blade view into Excel format and downloading it. Now I want to save it in a specified location, i.e: public/uploads/release Here is my controller:

JavaScript

This function downloads the excel file downloads folder. I want to save it in the location: public/uploads/release

Here is my route:

JavaScript

Advertisement

Answer

You can use the store method to store the file in the filesystem.

From the docs:

Exports can easily be stored on any filesystem that Laravel supports.

Default disk

JavaScript

Custom disk

JavaScript

Now ideally you would store the file in storage/app/public/uploads/release and create a symlink from public/storage/ to storage/app/public as explained here.

But if you really want to store it in public/uploads/release you could create new custom disk in config/filesystems.php. Something like:

JavaScript

Then you could use the custom disk to store the file:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement