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
Post a Comment