javascript - IE 8 - .files attribute workaround -


i've been trying figure out how attach document sharepoint list after creating item. able find code online this; however, after testing code in different browsers, doesn't work ie 8 , ie 9 because of .files attribute. there way go around this?

function addattachments(itemid) {     var filereader = {}, file= {};  /* here --------> */var files = document.getelementbyid('myfile').files;      for(var j=0; j< files.length; j++)     {         file = files[j];          filereader = new filereader();          filereader.filename = file.name;          filereader.onload = function(){             var data = this.result             n = data.indexof(";base64,") + 8;               data = data.substring(n);               $().spservices({                 operation: "addattachment",                  listname:'test',                  asynch: false,                  listitemid: itemid,                  filename: this.filename,                  attachment: data,                  completefunc: function (xdata, status){                 }              });          };           filereader.onabort = function (){         };           filereader.onerror = function(){         };           filereader.readasdataurl(file);      }//end of loop } 

thank in advance help!

yes, can use polyfill, implements missing functionality in unsupported browsers. there few polyfills file api listed on modernizr's html5 cross browser polyfills page.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -