Home > Web Front-end > JS Tutorial > body text

JavaScript implementation to limit upload file size_javascript skills

WBOY
Release: 2016-05-16 16:15:36
Original
1310 people have browsed it

Foreword:

In projects, functions such as uploading files and photos are often used, and the size of the uploaded files needs to be limited. Many plug-ins use background request verification, and there are relatively few front-end JS verifications. This article introduces a front-end JS method to conveniently determine the size of uploaded files.

The code is very simple. The key is how to use JS to get the file and then get the file size, and then judge the interception. Due to various historical reasons and IE's ActiveX control factors, the method of obtaining files may be different from other browsers, so you only need to make a little judgment.

JS code:

Copy code The code is as follows:



HTML code

Copy code The code is as follows:


A simple, light and fast method to use JS code to determine the file size is OK. As for the ActiveXObject object, if you are interested, you can delve into it. It can return different objects according to different input parameters. Usually, the function of this object and effects are also very useful and powerful.

That’s it for this article. Isn’t it a very simple and practical code? I hope you all like it.

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 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!