SHARE
TWEET

Untitled

a guest Jul 24th, 2019 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <input type="file" multiple (change)="onSelectedFile($event)"/>
  2.      
  3. images = [];
  4. onSelectedFile(e){
  5.     let listUrl = this.images.map(image => image["url"]);
  6.     const files = e.target.files;
  7.     let selectedFiles = [];
  8.     for (let i = 0; i < files.length; i++) {
  9.       let reader = new FileReader();
  10.       reader.onload = e =>
  11.         selectedFiles.push({ file: files[i], url: reader.result });
  12.       reader.readAsDataURL(files[i]);
  13.     }
  14.     console.log(selectedFiles);
  15.     console.log(selectedFiles.length);
  16.     let fileDistinct = selectedFiles.filter(x => listUrl.indexOf(x.url) < 0);
  17.     if(fileDistinct.length > 0){
  18.       this.images = [...this.images, ...fileDistinct]
  19.     }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top