我的Laravel存储目录中有一组目录。
路径是
\storage\app\public\docs
.
里面
docs
目录有一组包含HTML、CSS和JS的文件夹。
如果用户登录,我想访问这些文件夹/文件。
以下是我的路线:
Route::get('storage/{directory}/{subdirectory}/{page}', function ($directory,$subdirectory,$page)
{
if(!Auth::check()){
die('Unauth access');
}
$path = storage_path('app/public/' . $directory.'/'.$subdirectory.'/'.$page);
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;
});
例子:
网址:
http://localhost:8000/storage/docs/62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c/index.html
反应是加载成功。
但是索引中有一些外部css和js。html。
但它们不是响应中的负载。
js和css包含在包含的css和js目录中
62199911-74c61aaf688c0d374f23253218a12a9b81eaba4c
目录
当用户登录时(不适用于guess用户),是否有方法允许评估存储目录中的每个文件和文件夹。