我在laravel 5.8中有两个项目。首先在sub1.domain.com在sub2.domain.com中排名第二]
使用sub2,我保存图像和文件。我需要查看sub2和sub1中的图像和文件。
哪里是共享图像和文件的最佳目录存储?
我有一个共享主机。
谢谢。
公共磁盘用于要公开的文件无障碍。默认情况下,公用磁盘使用本地驱动程序,将这些文件存储在
storage/app/public
中。使它们可以从在网络上,您应该创建一个从public/storage
到storage/app/public
假设您的所有图像和文件都可以公开访问,请按照那些说明进行操作。
然后,您可以使用asset('storage/file.txt')
文件中的值来获取路径,而不是使用.env
来打印可公开访问的URL,该路径类似于"https://sub2.domain.com/images/"
,然后只需附加文件名即可。
或write a custom helper method,允许您指定子域,例如custom_asset('storage/file.txt', 'sub2')
您可以在公共文件夹中上载,因为符号链接很难制作cpanel
修改ur
filesystems.php
in
'public' => [
'driver' => 'local',
'root' => public_path('app/public/uploads'),
'url' => env('APP_URL').'/uploads',
'visibility' => 'public',
],
在上面的链接中您的上传路径将是>>
public/uploads
and
\Storage::url('example.png') to get full image url