How to remove files[] using javascript?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
13 views
When you load the image, each file has a "Delete" button. How to make removal of a single file that is not sent through the form?

$(document).ready(function() { $('#basicUploadFile').on('change', function () { var count_photo = this.files.length ; $('#ololo_photo').val(count_photo); if (Number($("#ololo_vid").val()) ==") { var count_vid = 0;} else { var count_vid = Number($("#ololo_vid").val()); } if (Number($("#ololo_doc").val()) ==") { var count_doc = 0;} else { var count_doc = Number($("#ololo_doc").val()); } if (Number($("#ololo_mus").val()) ==") { var count_mus = 0;} else { var count_mus = Number($("#ololo_mus").val()); } if (Number($("#ololo_opr").val()) ==") { var count_opr = 0;} else { var count_opr= Number($("#ololo_opr").val()); } cout_all=count_doc+count_vid+count_mus+count_opr+count_photo; if (this.files.length >10 || cout_all>=10) { $('#result').append('Limit! You cannot attach more than 10 attachments.'); $('#confirm').prop('disabled', true);} else { $('#confirm').prop('disabled', false); for (var i = 0; i < this.files.length; i++) { //$('#result').append(this.files[i].name + '
'); if (this.files[i].size > 1024 * 1024) { fileSize = (Math.round(this.files[i].size * 100 / (1024 * 1024)) / 100).toString() + 'MB'; } else { fileSize = (Math.round(this.files[i].size * 100 / 1024) / 100).toString() + 'KB'; } //$('#result').append(this.files[i].size + '
'); $('#result').append('Name:' + this.files[i].name + ' (' +fileSize + ') to Remove
'); } // Delete the attachment of documents $("#delete_photo").click(function(){ $('#result').html("); $("#basicUploadFile")[i].value = "; // Do this, but not working }); } }); });


Images upload via this input


And all it will look like this
by | 13 views

1 Answer

0 like 0 dislike
No way.
You can do value="" and it completely reset, but delete does not - access the list of files read-only.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
4 answers
0 like 0 dislike
1 answer
0 like 0 dislike
5 answers
110,608 questions
257,187 answers
0 comments
40,796 users