dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersBHANU PRAKASH BYSANI
Minu
Bibillis
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » ASP.NET »

Get the file size using javascript/jquery


Posted Date: 13 Jun 2012      Posted By:: s.sheela     Member Level: Silver    Member Rank: 2207     Points: 4   Responses: 3



Can you please help on this below requirement ?



We need to get the file size in client side before uploading the files to the server. The maximum allowed file size is 2 GB. It should not to go with ActiveX or FileAPI. Also we don't use the handler file , swf file or anyother server side functinality.

Is there any other ways to do this using JavaScript,core ajax or any client side scripting.

Please let me know if you need any more information.




Responses

#675426    Author: Prasad kulkarni        Member Level: Diamond      Member Rank: 8     Date: 13/Jun/2012   Rating: 2 out of 52 out of 5     Points: 3

You can directly get filesize using "Scripting.FileSystemObject" but it uses ActiveX control.
so you can use JQuery, check following example


var files = $('.form-videos :input[type=file]').get(0).files;
for (i = 0; i < files.length; i++)
{
if (files[i].size > 20971520)
//do your stuff here
}


Thanks
Koolprasd2003
[DotNetSpider MVM]



 
#675434    Author: Anil Kumar Pandey      Member Level: Platinum      Member Rank: 1     Date: 14/Jun/2012   Rating: 2 out of 52 out of 5     Points: 3

You an use the below sample javascript code for file size


function CheckFileSize()
{
var fSize = document.getElementById('fileuploadControl').files[0];
if (typeof file_obj != 'undefined')
{
if (fSize.size > 2000000)
{
alert('file size is greater than 2Mb');
return false;
}
}

return true;
}


Thanks & Regards
Anil Kumar Pandey
Microsoft MVP, DNS MVM



 
#675461    Author: s.sheela      Member Level: Silver      Member Rank: 2207     Date: 14/Jun/2012   Rating: 2 out of 52 out of 5     Points: 1

To KoolPrasad, Please let me know what are the Jquery plugins to be added.

To Anil Kumar Pandey
Thanks for your reply.document.getElementById But it won't work in firefox.






 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Validation for Unit Dimension eg. 5x6x7
Previous : How to integrate payapal integration with a sandbox test site in asp.net/sample code
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.