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);

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