Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

download file laravel s3

public function downloadAsset($id)
    {
        $asset = Asset::find($id);
        $assetPath = Storage::disk('s3')->url($asset->filename);

        header("Cache-Control: public");
        header("Content-Description: File Transfer");
        header("Content-Disposition: attachment; filename=" . basename($assetPath));
        header("Content-Type: " . $asset->mime);

        return readfile($assetPath);
    }
Source by laracasts.com #
 
PREVIOUS NEXT
Tagged: #download #file #laravel
ADD COMMENT
Topic
Name
6+9 =