How To Upload multiple image with size validation in JQuery



Hello Dev,

At the moment, i we’ll present you find out how to add a number of picture with measurement validation in jQuery. This text gives you easy instance of find out how to add a number of picture with measurement validation in jQuery. you’ll discover ways to add a number of picture with measurement validation in jQuery.

So let’s comply with few step to create instance of find out how to add a number of picture with measurement validation in jQuery.

Instance:


<html lang="en">
<head>
    <title>How To Add a number of picture with measurement validation in JQuery</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script> 
</head>
<physique>
<div class="container text-center">
    <div class="grid-stack">
        <enter sort="file" id="fUpload" a number of />
        <button>Save</button>
    </div>
    <script sort="textual content/javascript">
    $(doc).prepared(operate(){
        $('#fUpload').change(operate(){
            var fp = $("#fUpload");
            var lg = fp[0].information.size; // get size
            var gadgets = fp[0].information;
            var fileSize = 0;
           
            if (lg > 0) {
                for (var i = 0; i < lg; i++) {
                    fileSize = fileSize+gadgets[i].measurement; // get file measurement
                }
                if(fileSize > 2097152) {
                    alert('File measurement should not be greater than 2 MB');
                    $('#fUpload').val('');
                }
            }
        });
    });
    </script>
</div>	
</physique>
</html>



Komentar

Postingan populer dari blog ini

Laravel 8 Get HTTP Hostname

JQuery Drag And Drop Menu Example

Laravel 8 Share Social Media Button