禁止访问!您无权访问请求的目录。没有索引文档或目录受读取保护



从昨天起,我的laravel项目就遇到了一个问题。我有一个输入文件,该文件被上传到forder存储/app/public/uploads中。现在,当我想显示文件时,我有这样的消息:";禁止访问!您没有访问请求的目录的权限。没有索引文档,或者目录受到读取保护">

<td><a class="" style="text-decoration: underline;" href="{{ asset('storage/app/public') }}/uploads/{{ $row->file }}"  target="_blank" style="color:black;font-size:120%">{{ $row->name }}</a></td>

我该如何解决这个问题。

您需要公开该文件。

https://laravel.com/docs/8.x/filesystem#the-公用磁盘

运行手工命令php artisan storage:link

这将创建从public/storagestorage/app/public的符号链接

然后,您可以使用Laravel助手来提供文件

https://laravel.com/docs/8.x/helpers#method-存储路径

storage_path('app/public/uploads/' . $row->file)

最新更新