Monday 31 July 2017

File Extension Check

<html>
<head>
    <title>Girfa : Student Help</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script>
        function filecheck()
        {
            var extension = $('#file').val().split('.').pop().toLowerCase();

            if ($.inArray(extension, ['png', 'jpg', 'jpeg']) == -1) {
                alert('Sorry, invalid extension.');
               
            }
            else
                alert('ok Fine');

        }
    </script>
</head>
<body>
    Select File : <input type="file" name="file" id="file"/><br />
    <button onclick="filecheck()">Check</button>
</body>
</html>


No comments:

Post a Comment