禁止访问!您无权访问请求的目录。没有索引文档或目录被读保护
Access forbidden! You don't have permission to access the requested directory. There is either no index document or the directory is read-protected
从昨天开始,我的 laravel 项目就遇到了一个问题。我有一个输入文件,文件上传到 forder storage/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-public-disk
运行 artisan 命令 php artisan storage:link
这将创建一个从 public/storage
到 storage/app/public
的符号链接
然后您可以使用 Laravel 助手来提供文件
https://laravel.com/docs/8.x/helpers#method-storage-path
storage_path('app/public/uploads/' . $row->file)
从昨天开始,我的 laravel 项目就遇到了一个问题。我有一个输入文件,文件上传到 forder storage/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-public-disk
运行 artisan 命令 php artisan storage:link
这将创建一个从 public/storage
到 storage/app/public
然后您可以使用 Laravel 助手来提供文件
https://laravel.com/docs/8.x/helpers#method-storage-path
storage_path('app/public/uploads/' . $row->file)