[英]Can't make a public storage folder in laravel 5.2
My laravel project is setup with storage like this:我的 Laravel 项目设置了这样的存储:
-storage
-app
-services
And I have a filesystem setup for the app folder but I just recently setup a new one for services like so我为 app 文件夹设置了一个文件系统,但我最近刚刚为这样的服务设置了一个新的
services' => [
'driver' => 'local',
'root' => public_path('services'),
'visibility' => 'public'
],
My issue is that now when I get a file out of that folder and use the URL on the frontend, it says the document can't be found and it's because the URL actually prints out like this:我的问题是,现在当我从该文件夹中获取文件并使用前端的 URL 时,它说找不到该文档,这是因为 URL 实际上打印出来是这样的:
/storage/testfile.txt
where I'm expecting我期待的地方
/storage/services/testfile.txt
but I can't seem to get the URL to show correctly with this controller code:但我似乎无法使用此控制器代码正确显示 URL:
$file1 = 'testfile.txt';
$file2 = 'test2.txt';
$url1 = Storage::disk('services')->url($file1);
$url2 = Storage::disk('services')->url($file2);
if(Storage::disk('services')->exists($file1)){
$files[1] = public_path($url1);
}
if(Storage::disk('services')->exists($file2)){
$files[2] = public_path($url2);
}
$PDFfiles = json_encode($files);
dd($PDFfiles);
I don't really know how I can change this to link to a public folder, but I currently have no public driver in my filesystems.php file and in my public folder there is no storage folder at all我真的不知道如何将其更改为链接到公共文件夹,但目前我的 filesystems.php 文件中没有公共驱动程序,并且在我的公共文件夹中根本没有存储文件夹
I"m running laravel 5.2 so I can't run php artisan storage::link either我正在运行 laravel 5.2 所以我也不能运行 php artisan storage::link
How can I fix this so that I can display a file on my webpage with a public URL?我该如何解决这个问题,以便我可以在我的网页上显示带有公共 URL 的文件?
php artisan storage:link
only creates a symbolic link from /public/storage
to /storage/app/public
. php artisan storage:link
仅创建从/public/storage
到/storage/app/public
的符号链接。
You could either:你可以:
/storage/app/public
folder./storage/app/public
在/storage/app/public
文件夹中。 (use ln -s
) ln -s
)/public
folder./public
文件夹。storage
folder.storage
文件夹中检索某些文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.