LoginSignup
3
1

More than 5 years have passed since last update.

LaravelでStorageから取得したファイルをダウンロードさせる

Posted at

ダメな例

Laravel5.5のStorageのドキュメントに記載がなかったので、感覚的にこんな感じかな?

$file = Storage::get('file.jpg');
return response()->download($file);

と思ったけどダメだった。

正しい例

もっとシンプルに実現できた!

return Storage::download('file.jpg');

補足

Laravel5.6以降のドキュメントには普通に記載があります :thumbsup_tone2:
https://laravel.com/docs/5.6/filesystem#downloading-files
https://laravel.com/docs/5.7/filesystem#downloading-files

Laravel5.5でも大丈夫でした :stuck_out_tongue_winking_eye:

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1