This time I will bring youjQueryDetailed explanation of the method of judging uploadedpicturestype and size. What are theprecautionsfor jQuery to judge the type and size of uploaded pictures? The following is a practical case, let’s take a look.
JQuery is used here to determine the type and size of the uploaded image:
lastIndexOf()
method retrieves the specifiedstringfrom back to front, if If the specified character appears, the position of the character is returned. If not, -1 is returned, and the position is counted from 0.
toUpperCase()
method converts to uppercase letters
substring()
method intercepts a string. The first parameter is the starting position, and the second parameter is the ending position (if omitted, the end of the string will be intercepted by default), and # The difference between ##slice()and
substr()is that
substring()does not accept negative parameters
slice()The method is the same as the
substring()method, the difference is that it accepts negative parameters (if the parameter is a negative number, the position is calculated from the end of the string)
substr()Method to intercept a string, the first parameter is the starting position, the second parameter is the intercepted length (different from slice and substring), it is no longer recommended to use
What are the main APIs of jQuery
The above is the detailed content of Detailed explanation of how jQuery determines the type and size of uploaded images. For more information, please follow other related articles on the PHP Chinese website!