• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Check File Size Prior Uploading

 
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My webapp has a fileupload module.

Is there a way in Jquery to check the file size of the file that is to be uploaded so that the user gets notified regarding it?
(A funciton that gets called on blur??)

I googled at the net but found something like creating an ActiveXObject(some sort of MicrosoftFSO) which I am uncertain if its feasible.

Basically, I need to add this feature since the users will fill up some sort of a form but only to find out that when he submits the page, he will
get a message that the file size exceeds the limit. (Not user friendly I think)

Thanks.
 
Sheriff
Posts: 67269
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't be done. JavaScript has no access to the file system.

That's why the only solutions you'll see are ActiveX, Flash or Applet based.

(ActiveX, by the way, is IE-only.)
 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,

Thanks.

But I still google on the net to find the answer and I found this http://stackoverflow.com/questions/1440723/find-file-size-with-jquery.



It fires up a Head Request. I am a newbie in this Head request as I only used Get and Post.

Any thoughts here regarding this approach?
 
Bear Bibeault
Sheriff
Posts: 67269
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think!

Of what use is finding the size of a file on the server? I thought you were after the size of client file?
 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Of what use is finding the size of a file on the server? I thought you were after the size of client file?



Ahhh sorry.. Got it loud and clear..

I got carried away finding the solution to my problem..

Thanks..
 
Bear Bibeault
Sheriff
Posts: 67269
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem. If you want to find out info about the client system, you need something other than JavaScript.

Imagine the security nightmare if any old script on a page could poke around your file system!

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!