Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel File Downloaded from storage folder gets corrupted

Tags:

People also ask

How do I upload files to Laravel directly into storage folder?

Another way to store the uploaded file is to make use of Storage::putfile() method. To make use of the Storage Facade class you need to include the following class: use Illuminate\Support\Facades\Storage; The putfile() method will store the file given in the folder mentioned.

How do I delete files from storage folder in Laravel?

One way to delete a file from the public directory in Laravel is to use the Storage facade. To delete a file, you will need to follow the following steps: Step 1: Check to ensure that the folder and file exist. Step 2: Delete the required file.

How do I download from storage folder in Laravel 8?

Downloading file Downloading files in Laravel is even more simple than uploading. You can pass download() method with file path to download file. Same way, if you want to download file from the public folder, you can use download() method from Response class.


I tried to download jpg/png image from storage folder its gets corrupted after downloaded. This is my controller

public function download($filename) {

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

}

after open it look like this enter image description here

Even i used core php script to download still iam facing same problem.