我使用Laravel Framework 8.62.0并保存上传的图像,如下所示:
$contents = file_get_contents($imgUrl);
// $file_name = basename($url_upper);
$file_name = strtolower(substr($imgUrl, strrpos($imgUrl, '/') + 1));
$strg = Storage::disk('public_collectible_img')->put($file_name, $contents);我的public_collectible_img-driver如下所示:
'public_collectible_img' => [
'driver' => 'local',
'root' => storage_path('app/public/collectibles_img'),
'url' => env('APP_URL').'/collectible/image',
'visibility' => 'public',
],当我尝试在本地打开下面的url时,我会得到一个404-error。
http://localhost/my_project/public/collectible/image/1.jpg
该图像存在于文件夹中:

如何访问图像,正确的网址是什么?
谢谢你的回复!
发布于 2021-10-10 07:55:06
您必须在“存储”和“公共”文件夹之间创建一个符号链接。
为了使这些文件可以从网络上访问,您应该创建一个从公共/存储到存储/app/public的符号链接。
运行以下手工代码:
php artisan storage:link参考资料:https://laravel.com/docs/8.x/filesystem#the-public-disk
https://stackoverflow.com/questions/69506437
复制相似问题