如何使用新名称从存储中下载文件?

array:5 [▼
  "_token" => "6DsAz1lxff1fb3dELIbOlaYk7r8ctDrLAqBkFPCo"
  "book_id" => "10"
  "book_title" => "2-секундный ЛИН"
  "book_author" => "Пол Эйкерс"
  "book_link" => "http://localhost:8888/storage/books/20191001/PL4to/PL4tovCFenawOlamQAO7KDA81zkQfgP3Re9BV0tD.pdf"
]

我有文件路径和名称,该如何下载新名称的文件?

public function download(Request $request)
       {
           $data = $request->all();
           $filename = $data['book_title'].$data['book_author'];
           $str = str_replace(' ', '_', $filename);
           dd($data);
           $file->move($data['book_link'], $str);
           $contents = Storage::get('file.jpg');
       }

名称应为$ str

评论