浏览器展示图片和pdf文件

  1. public function uploadFile(Request $request)
  2. {
  3. $path1 = $request->file("file");// 获取上传的文件
  4. // $path1->store("public/images");
  5. $path1->storeAs("public/file","up.pdf");
  6. }

文件下载

public function download()
{
    $pathToFile = "storage/images/up.jpg";
    return response()->download($pathToFile);
    // return response()->download($pathToFile, $name, $headers);
}