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.

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

B logbook : PHP | Javascript | Laravel | CodeIgniter | VueJs | ReactJs | WordPress