How to Download Image in Laravel

In this section, we will see how to upload and download images in Laravel. There are two ways to download images in Laravel. First, you can use the HTML download attribute. Second, you can use the Laravel download method.

Example 1

Download Image in laravel using html download Attribute.

<a href="{{ Storage::url($file->image)}}" target="_blank" download>Download</a>  

Example 2

Download Image using laravel download method.

public function downloadImage(Image $image)
    $imagePath = Storage::url($image->image);

    return response()->download(public_path($imagePath));

In your blade file add below code.

<a href="{{ route('download.image',$image->id) }}" target="_blank">Download</a>  

Now create route for image download.

Route::get('image-download/{image}', [ImageController::class, 'downloadImage'])->name('download.image');
Download Image