Thursday, 20 February 2014

Check Image size and type using javascript in asp.net

 function GetFileSizetypeIMG() {
    var maxsize=2*1024*1024//1mb=1*1024*1024
        var aspFileUpload = document.getElementById("<%=Upload1.ClientID%>");
        var filesze = aspFileUpload.files[0].size;
        var fileName = aspFileUpload.value;
        var ext = fileName.substr(fileName.lastIndexOf('.') + 1).toLowerCase();
        if (!(ext == "zip")) {
            alert("Invalid file type, must select a (*.zip) file");
            return false;
        }
        if (filesze > maxsize) {
            alert("Selected file not more than " + maxsize/(1024*1024)+"MB");
            return false;
        }
        return false;
    }

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...