Friday 11 July 2014

Check uploaded file size in asp.net using javascript


//HTML

<asp:FileUpload ID="upl1" runat="server" onchange="CheckFileSize(this.id);" />

//SCRIPT

<script type="text/ecmascript">
 function CheckFileSize(upid) {
                var maxsize = 5 * 1024//1kb=1*1024
                var aspFileUpload = document.getElementById("" + upid + "");
                var filesze = aspFileUpload.files[0].size;
                if (filesze > maxsize) {
                    alert("Maximum file size is " + maxsize / (1024) + "KB");
                    return false;
                }
}

</script>

No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...