File Downloads

Livewire supports triggering file downloads for users with a simple, intuitive API.

To trigger a file download, you can return a Laravel file download from any component action.

1class ExportButton extends Component
3 public function export()
4 {
5 return Storage::disk('exports')->download('export.csv');
6 }
1<button wire:click="export">
2 Download File

Livewire should handle any file download that Laravel would. Here are a few other utilities you might use:

1return response()->download(storage_path('exports/export.csv'));
1return response()->streamDownload(function () {
2 echo 'CSV Contents...';
3}, 'export.csv');
← Previous Topic

File Uploads

Next Topic →

Query String