Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Check File Size before Upload or Get Image Size before Upload jQuery

Jan 21, 2014
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.

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.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

0 comments :

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.