Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript HTML file
hi all,
 
how can i find a file's size before uploading it? using javscript with activex is not supported by many browsers. but still it is possible on client side (gmail does it in all browsers when you attach a file on client side itself). plz help...
 
thanks & regards, AR
Posted 5-Feb-10 19:47pm
AR@JR634
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

but that requires sending the file to the server. there is a client side method for this that gmail uses, but i cant find how...
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

GMail's attachment upload uses Flash to find the size and display the progress.
 
Here is another one that does the same thing: SWFUpload[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

swfupload is doing the job just the way i wanted it...thanks a lot
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

you cant use javascript but you can use ajax.
-------------------
 
Answer 2:
 
Use something like this:
 
if (FileUploadControl.HasFile)
            {
              double FileSize = FileUploadControl.PostedFile.ContentLength;
              double VerifyFileSize = FileSize / 1024 / 1024;
              bool Status = false;
             
              if (VerifyFileSize > 1)// where "1 MB" is the size
              {
                  Status = true;
              }
 
                FileSizeStatusLabel.Text = FileSize.ToString() + " " + (Status ? "to big" : "size ok");
            }
 
I mentioned Ajax to get rid of the post back. However, as I said you cant get it using client js
  Permalink  
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

As far as I can tell, an iFrame is doing the actual submission of the file, while you look at the rest of the page. I'm not sure how it's working out the file size, I did some googling and couldn't find any info. Perhaps they are faking it ?
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Mathew Soji 274
1 BillWoodruff 270
2 Afzaal Ahmad Zeeshan 244
3 Sergey Alexandrovich Kryukov 240
4 Raul Iloc 160
0 OriginalGriff 6,219
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,103
3 Manas Bhardwaj 4,549
4 Maciej Los 3,845


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 18 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100