Laravel File Downloaded from storage folder gets corrupted

I believe that the Laravel framework might be introducing whitespace which might be ruining the header() function.

Use ob_end_clean() before your first header() call to remove any extra whitespace.

ob_end_clean();
$headers = array(
‘Content-Type: image/png’,
);
return response()->download(storage_path() . ‘/’.$filename, ‘final.png’, $headers);

https://exceptionshub.com/laravel-file-downloaded-from-storage-folder-gets-corrupted.html

Blogbook : PHP | Javascript | Laravel | Corcel | CodeIgniter | VueJs | ReactJs | WordPress