Introduction:
Here
I will explain how to check file size before upload in jQuery or jQuery get image size
before upload using jQuery uploadify plugin in asp.net.
Description:
In previous articles I explained integrate Facebook login authentication, integrate twitter login authentication, jQuery randomly change color of div, jQuery upload multiple files using uploadify plugin in asp.net, jQuery upload multiple files using multiple file upload plugin in asp.net and many articles relating to jQuery, asp.net, c#, vb.net. Now I will explain how to get file or image size before upload in jQuery using jQuery uploadify plugin in asp.net.
In previous articles I explained integrate Facebook login authentication, integrate twitter login authentication, jQuery randomly change color of div, jQuery upload multiple files using uploadify plugin in asp.net, jQuery upload multiple files using multiple file upload plugin in asp.net and many articles relating to jQuery, asp.net, c#, vb.net. Now I will explain how to get file or image size before upload in jQuery using jQuery uploadify plugin in asp.net.
By using jQuery uploadify plugin we can check image size before upload easily just setting sizelimit
property like as shown below
$("#<%=upload1.ClientID %>").fileUpload({
'uploader': 'scripts/uploader.swf',
'cancelImg': 'cancel.png',
'buttonText': 'Select Files',
'script': 'Handler.ashx',
'folder': 'images',
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
'multi': true,
'auto': true,
'sizeLimit': (200 * 1024), //200
KB
onError: function
(a, b, c, d) {
if (d.type === "File
Size") {
$("#lblmsg").html('File Size Should not exceed 200 KB');
}
},
onComplete: function
() {
$("#lblmsg").html('');
}
});
|
If you observe above code I set property 'sizeLimit' property to restrict upload image size to 200 KB
Demo
|
If you want complete code download it from attached sample
Download sample code attached
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
0 comments :
Note: Only a member of this blog may post a comment.