您可以存储/程序/公共和公共/存储之间的symbolink链接,以便您可以访问您的文件,通过运行
php artisan storage:link
更多信息Here。
然后你就可以做出这样的路径来访问文件:所以在这种情况下
Route::get('pdffolder/{filename}', function ($filename)
{
$path = storage_path('app/public/pdffolder/' . $filename);
if (!File::exists($path)) {
abort(404);
}
$file = File::get($path);
$type = File::mimeType($path);
$response = Response::make($file, 200);
$response->header("Content-Type", $type);
return $response;
});
,如果你保存的文件名为123.pdf
PDF格式的文件夹中storage/app/public/pdffolder
you can access it by http://yourdomain.com/pdffolder/123.pdf
你必须调整它有点,但我认为这可以帮助你。