Skip to content
Snippets Groups Projects
Commit c7174074 authored by Chris Lawton's avatar Chris Lawton
Browse files

remove existing listed files from file upload

parent 4916a79e
No related branches found
No related tags found
No related merge requests found
...@@ -21,9 +21,11 @@ $(function () { ...@@ -21,9 +21,11 @@ $(function () {
// Show list of selected files for upload on input[type=file] // Show list of selected files for upload on input[type=file]
$('input[type=file]').change(function() { $('input[type=file]').change(function() {
// remove any existing files first
$(this).siblings('.form__file').remove();
for (let i = 0; i < $(this)[0].files.length; ++i) { for (let i = 0; i < $(this)[0].files.length; ++i) {
$(this).parents('.form__item').prepend(` $(this).parents('.form__item').prepend(`
<p>${$(this)[0].files[i].name}</p> <p class="form__file">${$(this)[0].files[i].name}</p>
`); `);
} }
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment