LaravelでStorageから取得したファイルをダウンロードさせる
1364 ワード
ダメな例
Laravel5.5のStorageのドキュメントに記載がなかったので、感覚的にこんな感じかな?
$file = Storage::get('file.jpg');
return response()->download($file);
と思ったけどダメだった。
正しい例
もっとシンプルに実現できた!
return Storage::download('file.jpg');
補足
Laravel5.6以降のドキュメントには普通に記載があります
https://laravel.com/docs/5.6/filesystem#downloading-files
https://laravel.com/docs/5.7/filesystem#downloading-files
Laravel5.5でも大丈夫でした
Author And Source
この問題について(LaravelでStorageから取得したファイルをダウンロードさせる), 我々は、より多くの情報をここで見つけました https://qiita.com/tech31/items/564b0b8bb8edc90bdec8著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .