There is no problem with the Linux file path when deploying the window and Linux projects

There is no problem with the Linux file path when deploying the window and Linux projects

I haven't written a blog for a long time. Last week, I tested the project and found some bugs. One of them is a bit confusing. The description is as follows:

The project is deployed on Windows, and the image upload function is normal. When deployed on a Linux server, an inexplicable error occurs (probably because I am mentally retarded and actually forgot* Differences between Linux and Windows file directories*)

Normally it should be like this:


insert image description here

In fact, it is like this:


insert image description here

Tudou, who had never encountered such a problem, was also a little confused. No matter what, I restarted the project first, but it didn't work . Then I checked Tomcat, but it still didn't work . I was in a difficult situation. As a senior rookie programmer, I naturally have the third, fourth, and fifth solutions (baidu, google, etc.). With the spirit of not giving up, I keep on going. OK, brother, I found it. Hahahaha. As for my mood at this moment, it is like I met you in the vast crowd.
After careful analysis of the problem, it turns out that the file storage path under Windows is:

path += "\\" + dirName + "\\" + ymd + "\\";

The result on Linux will be:


insert image description here

This is obviously different from the path we expected. Yes, I believe that students with a little computer knowledge can see what the problem is. That's right, just change \ to / and it will be ok. It's really smart and refreshing, but a moment of stupidity ruined half a day.
Compare this to:

//Note that there are differences between Linux and Windows. Linux uses \ and Windows uses //
	/*path += "\\" + dirName + "\\" + ymd + "\\";
	pathsrc += "\\" + dirName + "\\" + ymd + "\\";*/
	path += "/" + dirName + "/" + ymd + "/";
	pathsrc += "/" + dirName + "/" + ymd + "/";

Summarize

The above is what I introduced to you. There is no problem with the Linux file path for window and Linux project deployment. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Steps to modify the MySQL database data file path under Linux
  • Detailed explanation of common files and command paths in Kali Linux
  • How to query the full path of the running file in Linux
  • How to implement tar packing of specified path files in Linux
  • How to get the absolute path of a file through a file descriptor in Linux
  • How to view the path of the MySQL configuration file on the Linux server
  • Linux changes the path of mysql database files
  • Extract specific file paths in folders based on Linux commands

<<:  MySQL 8.0.15 download and installation detailed tutorial is a must for novices!

>>:  JD Vue3 component library supports the detailed process of mini program development

Recommend

Implementation of navigation bar and drop-down menu in CSS

1. CSS Navigation Bar (1) Function of the navigat...

How to optimize MySQL group by statement

In MySQL, create a new table with three fields, i...

JavaScript to implement retractable secondary menu

The specific code for implementing the retractabl...

Docker cleaning killer/Docker overlay file takes up too much disk space

[Looking at all the migration files on the Intern...

CSS to achieve Cyberpunk 2077 style visual effects in a few steps

background Before starting the article, let’s bri...

Detailed explanation of display modes in CSS tags

Label display mode (important) div and span tags ...

Problems with index and FROM_UNIXTIME in mysql

Zero, Background I received a lot of alerts this ...

Summary of MySQL common functions

Preface: The MySQL database provides a wide range...

MySQL Installer Community 5.7.16 installation detailed tutorial

This article records the detailed tutorial of MyS...

How to use VIM editor in Linux

As a powerful editor with rich options, Vim is lo...

CSS3 radar scan map sample code

Use CSS3 to achieve cool radar scanning pictures:...