I am working on a project, which contains many pictures to be displayed. For the convenience of later maintenance, I plan to upload the pictures and use absolute paths to reference them for display, so that if the pictures are updated or added later, There is no need to change the project, just go to the image maintenance place to operate it.
but! Now when I test locally, I write
background: url(D:\dev\uploadfile\test picture 1.png) no-repeat;
The result is an error: Not allowed to load local resource: file: ///D:/dev/uploadfile/Preserved value card replacement process.png
Probably means that absolute paths cannot be used. But I think it should be usable, and why does it add file:/// in front of my path? Is this the reason why my pictures cannot be accessed?
In addition, it should not be a problem with forward and back slashes, because I have tried changing them.
In addition, I have to use absolute paths, because using relative paths requires putting all the pictures into the project. This post-maintenance will be very troublesome, so if you want to tell my friends who use relative paths, can you solve the post-maintenance problem? If you have a plan, you can also put it forward
Not allowed to load local resource
For security reasons, accessing local files in this way is not allowed.
You can start an http service under the local image folder. Whether to use nginx, python, nodejs or others depends on personal preference.
Go to the service background through the interface every time or regularly to get the latest image URL, and then dynamically configure it into the background.
Here you need the image service background to have an http service to provide to the front page