aFarkas / webshim

[DEPRECATED] Webshims Lib is a modular capability-based polyfill-loading library
http://aFarkas.github.com/webshim/demos/index.html
MIT License
1.42k stars 201 forks source link

Is the FileReader shim actually useful without File? #348

Closed scribu closed 10 years ago

scribu commented 10 years ago

In the demo code, you use file = $(this).prop('files')[0]; to get the file attributes, but the File constructor doesn't seem to be supported in IE8 and IE9, which presumably are exactly the browsers this shim is intended for.

I don't have an old instance of IE available to test, which is why I'm asking here. Thanks for reading.

1DMF commented 10 years ago

I have used

$('#fp_file').on('change',function() {
 fileSelected($(this));
}); 

function fileSelected(ele)
{    
var file = $(ele).prop('files')[0];
 ....

Which is working in IE9, but I cannot for the life of me work out how to use the options

I've tried...

webshims.setOptions('filereader',{extensions : '*.pdf;*.doc;*.docx'}); 

But no joy.

Where and how are we meant to be providing the element options?

also why are you even using this shim wrapper for FileReader?

FileReader states... This plugin is unmaintained and unsupported as File API is now widely supported (almost 80% global support – http://caniuse.com/fileapi) Please use https://github.com/moxiecode/moxie instead of this polyfill if needed.

1DMF commented 10 years ago

I don't get this now it doesn't work at all ...

UPDATE: You must use the class 'ws-filereader' on the input/file element within the HTML - for some bizarre reason?

Also it ignores / doesn't work with the HTML5 attribute 'accept' and I have no idea how I pass the options.

Can anyone clarify if this shim actually works and if so how?

aFarkas commented 10 years ago

Closing this. Duplicate of https://github.com/aFarkas/webshim/issues/319

Watch out for version 1.14.0. Something nice will be there for you :-)

aFarkas commented 10 years ago

I have now released the new version of filereader. A simple demo is included in the demo package: http://afarkas.github.io/webshim/demos/demos/filereader/

The filepicker now fully supports multiple and accept attribute.

Unfortunatley, for the submit proccess we need php, why this demo does only patially work on gh-pages.

But this demo showcases one simple usecase of filereader: Creating a simple multi-upload with a small preview.

Have fun.