0

i am trying to use angular file upload to filter and make user upload kml files only (map) . i have a working code where i use picture files

this.uploader.filters.push({
        name: 'imageFilter',
        fn: (item, options) => {
            var type = '|' + item.type.slice(item.type.lastIndexOf('/') +
            1) + '|';
            return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1;
        }
    });

simply putting |kml| with other or just by itself is not working. any solutions?

i saw an example of xml file also here it is

      function xmlFilter(file) {
      var validMimeTypes = ['application/xml', 'text/xml'];
      if (validMimeTypes.indexOf(file.type) !== -1) {
      return true;
   }
    }

     this.uploader.filters.push({name: 'xmlFilter', fn: xmlFilter});
   }   
jsPlayer
  • 1,195
  • 7
  • 32
  • 56
  • can you eloborate bit more? Provide the code and sample value you used to call the above filter. – Kalyan May 15 '17 at 23:15
  • it similar to this question but i want kml files filteres instead of jpef, png http://stackoverflow.com/questions/30589321/nervgh-angular-file-upload-how-do-i-restrict-the-file-formats-to-say-jpeg-and – jsPlayer May 16 '17 at 00:11

0 Answers0