How to handle duplicate files while uploading from the queue? #733
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
How i can handle duplicate files while uploading, for example, if i want to remove an item from an array, then, i can use item.remove(), like wise, if want to check for duplicate files in queue and if want to handle duplicates.
Is there anything in this ng2-file-upload, please?
@shakthi23 you want to check the files queue and see if there are files with the same name
now when it comes to removing a single file you can just
.splicethe index of the duplicate file from the arrayother people are doing this too -> https://github.com/valor-software/ng2-file-upload/issues/609
you don't need ng2-file-upload . Just use this...
openUploadDoc(event) {
for (let i = 0; i < event.target.files.length; i++) {
if (this.bulkUploadDoc.length > 0 &&
this.bulkUploadDoc.some(x => x.fileName === event.target.files[i].name)) {
alert('file alraedy exist');
} else {
this.bulkUploadDoc.push(event.target.files[i]);
}
}
}
this.uploader.onAfterAddingFile = (item) => {
item.remove();
if (this.uploader.queue.filter(f => f._file.name == item._file.name).length == 0) {
this.uploader.queue.push(item);
} else {
alert("file duplicated");
}
};