[英]Get full path to file with Laravel Storage
我正在使用 Laravel 5.6 Storage API 将我的文件public/storage/images
在public/storage/images
。 这工作正常。 当我想检索这些文件之一的完整 URL 时,我使用
$path = Storage::disk('public')->url('images/' . $url);
这返回
但是由于我的服务器设置为忽略public
,因此该地址不会返回图像。 相反,这个地址:
返回图像。 有没有办法使用 Laravel 的 API 生成这个地址,而不是进行丑陋的查找和替换?
尝试此步骤以ignore public
路径中的ignore public
1)Rename `service.php` to `index.php` in your root drive
2)copy `.htaccess` file from public folder and paste into root drive
现在在 url 中不公开地运行您的代码
在根目录中创建一个 .htaccess 文件并添加
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ public/index.php/$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.