• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reading file size at client side using actionscript

 
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody, I am Chaitanya, I want to upload files to server in my application and I want to restrict the file size say 1MB for an image, what I am thinking to do is run an actionscript function to check the file size at server side as soon as the user clicks submit button, I will force the client to install flash player plugin and enable java script.

Is the approach right? Thank you all in advance. Have a good day.
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you people may say forcing the user to install a plugin for a silly upload is not the right way.

I say forcing the user is the right approach because instead of just uploading it to the server and checking the file size and breaking the request and asking him to upload the specified size file is somewhat time consuming. I think prevention is better than cure here.

What you say.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How else do you use ActionScript without the user installing a version of Flash Player?
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:How else do you use Action Script without the user installing a version of Flash Player?



Provided the flash player is installed on the browser, or else the file size is calculated at the server. Moreover I already said I will force the user to install flash player. many sites wont run without JavaScript enabled or flash player installer, such as Orkut.

Moreover I wont suggest programmers to follow this method, I give up. Because if the client uses Google chrome browser the file path cannot be taken into java script, chrome will only return the file name, not the entire path, where as Mozilla and IE will return the entire path. So in chrome we cannot find the file size.

 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you need JavaScript to upload a file? JavaScript can't access the file system in the way you would need it to to unless you use browser specific code. ActionScript can, and should be cross browser. The normal mechanism though would be to check the size server side.
 
chaitanya karthikk
Ranch Hand
Posts: 806
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:Why do you need JavaScript to upload a file?



Hi Paul, you, misunderstood me. Actually the aim was to find the file size at the client side instead on finding the size at server and dropping the request if the size exceeds.

So somehow I should be able to enter the local drive and find the file size. Where javascript does not have such kind of abilities. So I supposed to choose action script. Action script can enter the local disk and find the file size. I have done this successfully from the browser.

Now what I have did his, read the html file input value from javascript and then call an appropriate actionscript's method to find the file size.

It went right on IE and mozilla, but didnt work properly in chrome, because the browser's sand box in not allowing javascript to read the html file's input value, its only giving the file name, where the entire path is required.

So I dropped the idea. Hope now you understand what I was trying to do.
reply
    Bookmark Topic Watch Topic
  • New Topic