<input type="file" id="fuUpload" />
<span id="lblMessage" style="color: red;"></span>
<br/>
<input type="button" id="btnUupload" value="Upload" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$("#btnUupload").bind("click", function () {
$("#lblMessage").html("");
var file = $("#fuUpload");
var size = parseFloat(file[0].files[0].size);
var maxSizeKB = 20; //Size in KB.
var maxSize = maxSizeKB * 1024; //File size is returned in Bytes.
if (size > maxSize) {
$("#lblMessage").html("Maximum file size " + maxSizeKB + "KB allowed.");
file.val("");
return false;
}
});
});
</script>
Browser Compatibility
The above code has been tested in the following browsers only in versions that support HTML5.
* All browser logos displayed above are property of their respective owners.