Is there a way to paste files into an input?
Basically I want to copy a file on the computer / Internet and by placing the mouse inside the input zone, when doing Crtl-v (paste) the input detects that command. Is there a way to do this?
HTML
<div class="card bg-light mb-3" style="width:700px; height:300px">
<div class="card-header">Attachment</div>
<div class="card-body att">
<input type="file" id="files" multiple (change)="detectFiles($event)" accept="image/*">
<div class="grid-container">
<div *ngFor="let url of items">
<div class="grid-item">{{url.fileType}} {{url.filename}}</div><span class="delete" (click)="deleteImage(Imagens[0])"><img>x</span>
</div>
</div>
</div>
</div>
Component
detectFiles(event) {
var files = event.target.files;
for (let index = 0; index < files.length; index++) {
const item: any = {
filename: event.target.files[index].name.split('.')[0],
fileType: event.target.files[index].type.split("image/").join(""),
fileSize: event.target.files[index].size,
number: index
};
this.items.push(item);
this.filename = this.items[0].filename;
this.fileType = this.items[0].fileType;
this.fileSize = this.items[0].fileSize;
console.log(this.items)
const reader = new FileReader();
reader.onload = (e: any) => {
item.url = e.target.result;
}
reader.readAsDataURL(files[index]);
}
}