This time I will show you how to get the type and size of the uploaded image, and what are the precautions for getting the type and size of the uploaded image. 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()
The method retrieves the specified string from back to front. If the specified character appears, Then return the position of the character, if not, return -1, the position starts counting 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), which is the same asslice()# The difference between ## and
substr()is that
substring()does not accept negative parameters
slice()The method is the same as
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 intercepts the string, The first parameter is the starting position, and the second parameter is the length of interception (different from slice and substring). It is no longer recommended to use
How to use vue to request local json
The above is the detailed content of How to get the uploaded image type and size. For more information, please follow other related articles on the PHP Chinese website!