php - When laravel is deployed to a linux server, the image cannot be displayed. If the default path does not set the public directory, it will be OK, but the css style will be messed up.
怪我咯
怪我咯 2017-05-16 13:03:33
0
3
546

The server environment is the LNMP environment,
the computer is the LAMP environment,

The picture directory is a sibling directory of public;

The image path can be displayed on the local machine, but when placed on the server, external access cannot display the image, unless I set the default access path of nginx to the public superior directory, but in this case, the css style path is Something went wrong;

The path of the picture is www.xxx.com/../uploads/asdads.jpg or something like this.
There is no problem in the LAMP environment, but it will not work in the server. What is the problem?

I suspect that nginx settings are missing. So I wanted to ask.


The path is fine on this machine. I found that when the browser accesses the server, it seems to ignore ../. I have placed the save folder in the public directory.

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(3)
刘奇

Based on your description, I guess there is something wrong with the path settings. You can use the development mode in the browser to see where the paths of the images and Js point to respectively, and whether they are the same as you expected.

给我你的怀抱

First check whether the uploads directory has read and write permissions. Secondly, if it is ignored, try the absolute path?

世界只因有你
  • Confirm whether the file name is correct

  • Public files can directly specify the absolute path in nginx

server {
    #忽略部分代码
    location /public/ {
        alias  "D:/www/code/public/";
    }
    
    location / { ... }
    #忽略部分代码
    
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template