Welcome to the Linux community forum and interact with 2 million technicians. We all know that windows is compatible, while LINUX is running normally locally. After uploading to the server, the image is not displayed. The image link is the absolute path var ..., but I remember that this path has been processed as a relative path.
Welcome to the Linux community forum, and interact with 2 million technical staff> as we all know, What Is \ and/in windows, while what is in LINUX is/running normally locally in the program, after uploading the image to the server, it is found that the image is not displayed. The image link is the absolute path var /..., it contains \, but I remember that this path has been processed as a relative path.
Welcome to the Linux community forum and interact with 2 million technicians>
As we all know, What Is \ and/in windows, while what is in LINUX is/
The program runs normally locally. After being uploaded to the server, the image is not displayed. The image link is the absolute path var /..., it contains \, but I remember that this path has been processed as a relative path.
$ Path = dirname (_ FILE __))).'\\';
$ Search = array ($ path ,'\\');
$ Replace = array ('','/');
Return str_replace ($ search, $ replace, $ this-> tempfolder). $ this-> filename_prefix.#public.'.jpg '; |
As you can see, the first line of code is used in LINUX.
The solution is to use the PHP pre-defined constant DIRECTORY_SEPATRATOR to replace path delimiters like '\' and '/'. In the past, I thought that since windows and LINUX support/, they all use, this is correct. However, we can see from this example that it is dangerous to process the path string, so it is best to use DIRECTORY_SEPATRATOR.