Home > Article > Web Front-end > Using js to get the uploaded file name is purely for beautification_javascript skills
Why use js to get the uploaded file name? In fact, it is purely for beautification and friendliness.
However, it is not like what is circulated on the Internet. Use path.substring(path.lastIndexOf('/') 1);
This is how it works. Many problems will arise from time to time.
For example, the value of the input form in Firefox can obtain the file name by default, while IE displays the file path.
So we need to treat it differently. Under Firefox, lastIndexOf('/') gets -1, but under IE, the directory displays backslashes. Of course, under Linux
, others What the browser obtains is forward slash / (it has not been proven that the value obtained by the browser file under Linux will be the full path);
You have to use two judgments: