Home > PHP Framework > Laravel > body text

Solve the problem that after laravel uploads images, there are images in the directory, but they cannot be accessed (404)

藏色散人
Release: 2021-02-15 09:24:46
forward
4365 people have browsed it

The following column of Laraveltutorial will introduce to you how to solve the problem that there are pictures in the directory but cannot be accessed (404) after laravel uploads pictures. I hope it will help. Friends in need help!

Solve the problem that after laravel uploads images, there are images in the directory, but they cannot be accessed (404)

After laravel uploads pictures, there are pictures in the directory, but they cannot be accessed (404)

1. Problem description

The Laravel background uploads the image successfully and returns the access link, but when accessing the image, a 404 error occurs. Have you checked whether there are images in the corresponding directory?

2. Solution

  • As long as the public directory of the Laravel project can be accessed, access to other directories is not allowed, and images are uploaded to the storage directory by default, resulting in images The link is fine, but the image cannot be accessed.
  • How to do it? It's very simple. Create a file soft link under public
  • Execute the command: php artisan storage:link
  • After the command is executed, There will be an extra public/storage in the project.
  • This storage is a soft link, which points to the storage/app/public directory.
  • public/storage (soft connection) → storage/app/public
  • Then you can use the address to directly access the photos in public!

The above is the detailed content of Solve the problem that after laravel uploads images, there are images in the directory, but they cannot be accessed (404). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template