Detailed explanation of how jQuery determines the type and size of uploaded images

php中世界最好的语言
Release: 2018-04-23 11:16:43
Original
2262 people have browsed it

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:

    
  

图片格式为:

图片大小为:

Copy after login

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()andsubstr()is thatsubstring()does not accept negative parameters

slice()The method is the same as thesubstring()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

I believe you have mastered it after reading the case in this article For more exciting methods, please pay attention to other related articles on the php Chinese website!

Recommended reading:

What are the main APIs of jQuery

##Detailed explanation of the use of var and let in the for loop in jQuery


Detailed explanation of the use of js built-in methods and objects

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!