1

I need to detect the size of the file before upload.

I need it to work in IE8, thus not HTML5
It needs to be entirely client side.
I need to be able to specify file size limit.

I am aware that ActiveX can be used, but I cannot use that due to it requiring the user to 'permit' it.

I have tested BlueImps plugin, but it doesn't seem to work and the documentation does not seem to state browser support.

Can anyone suggest a plugin/method with fits with my criteria.

Passerby
  • 9,715
  • 2
  • 33
  • 50
Jez D
  • 1,461
  • 2
  • 25
  • 52
  • Check [this question](http://stackoverflow.com/q/13512009/1300817). It seems to be in plain javascript using the `File API`, but does not work on IE. – Raul Rene Feb 13 '14 at 09:29
  • @RoyiNamir thanks for your comment. Uploadify would be my preferred alternative. Unfortunately, appears to be dependent on PHP, which the server does not support. – Jez D Feb 13 '14 at 09:34
  • @JezD _dependent on PHP_ ??? – Royi Namir Feb 13 '14 at 09:35
  • I think using flash can help to you – Farkhat Mikhalko Feb 13 '14 at 09:35
  • 1
    Uploadify is not dependent on PHP, you can freely use it with any other server side language. It doesn't do anything more than upload a certain POST request to a certain server-side address. – Mateusz Papiernik Feb 13 '14 at 09:36
  • This is not possible without the File API or Flash / ActiveX. – Ja͢ck Feb 13 '14 at 09:36
  • 1
    @RoyiNamir Have just re-read the uploadify docs. Yep, it seems I can post to any serverside uploaded file handler – Jez D Feb 13 '14 at 09:38
  • Having said that , I just tested their old version with pure ie8 ( VM) and it doesn't work... let me see if it's relates to flash installed or not. – Royi Namir Feb 13 '14 at 09:39

1 Answers1

0

If you're willing to introduce a dependency on Flash, then you could use that to get the file size (and handle the upload too).

Flash supports file-selection via the FileReference class, which gives you access to some metadata including the file size.

With some help from the ExternalInterface class, you could call a JavaScript function and give it this information.

You could then upload the file from Flash instead of with the usual input element, if the file size is appropriate.

Check out YUI's uploader for a really easy-to-use and well-documented free component that handles all this for you (you only need to write a little JavaScript, and you can style the pre-built Flash component however you want).

Farkhat Mikhalko
  • 3,565
  • 3
  • 23
  • 37