0

http://afarcas.github.io/webshim/demos/demos/filereader.htmlにある WebShims ドキュメントから、WebShims でFileReader を使用する例を示しています。それに続いて、私は今このコードを持っています

 <input class="ws-filereader" id="userFiles" multiple type="file"/>

 //Added Mordenizr and JQuery and WebShims library
 $.webshims.polyfill();

 $(function()
 { 
     $('#userFiles').on('change', function (evt) 
     { 
         var reader, file; 
         reader = new FileReader(); 
         reader.onload = function (evt) 
         { 
               var fileData = evt.target.result; 
         }; 
         file = $(this).prop('files')[0]; 
         reader.readAsDataURL(file); 
     }); 
 });

これをIE9で実行すると、userFilesの変更時にコードが入力されますが、取得するために呼び出すと

 console.log($(this).prop('files').length);

それは 0 を返します。何が問題なのですか?

電源を入れると

 $.webshims.setOptions('debug', true);

コンソールがくれます

 Unable to get value of the property 'input': object is null or undefined.

質問https://github.com/Jahdrien/FileReader/issues/46に投稿された同様の問題があり、WebShimsが FileReader の IE9 をサポートしていると書かれています

4

1 に答える 1

0

問題は、ファイル API が IE 10 まで IE に導入されなかったことです。

http://msdn.microsoft.com/en-us/library/ie/hh673542%28v=vs.85%29.aspx

このポリフィルのリストは、回避策を見つけるのに役立つ場合があります。

https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills#wiki-file-api

于 2014-02-10T12:57:38.230 に答える