1

I managed to check the file extension type and detect fake files but the problem that I'm facing now is after the alert message(alert that the image is fake) the details of the file are still being displayed in the table. How to remove the details from being display in the table after the alert message.

https://i.stack.imgur.com/9a2x4.png

Here's the code of my work: https://jsfiddle.net/auwhk7v1/1/

Here's one of the code that displaying details of the files:

vpb_added_files_displayer += '<tr id="add_fileID' + vpb_file_id + '" class="' + new_classc + '"><td>' + vpb_file_icon + ' ' + this.vpb_files[i].name.substring(0, 40) + '</td><td><span id="uploading_' + vpb_file_id + '"><span style=color:blue;>Ready</span></span></td><td>' + vpb_actual_fileSize + '</td><td><select class="form-control required type_doc_'+vpb_file_id+'" id="type_doc" name="type_doc" value="" title="File Type for document/photo" onchange="get_doc_type(this.value, \'' + vpb_file_id + '\')" required/><option value="0">Please Select</option>'+load_checklist('type_doc', vpb_file_id)+'</select></td><td><span id="remove' + vpb_file_id + '"><span class="vpb_files_remove_left_inner" onclick="vpb_remove_this_file(\'' + vpb_file_id + '\',\'' + this.vpb_files[i].name + '\');">Remove</span></span></td></tr></div>';
vpb_added_files_displayer2 += '<tr id="add_fileID' + vpb_file_id + '" class="' + new_classc + '"><td>' + vpb_file_icon + ' ' + this.vpb_files[i].name.substring(0, 40) + '</td><td><span id="uploading_' + vpb_file_id + '"><span style=color:blue;>Ready</span></span></td><td>' + vpb_actual_fileSize + '</td><td><select class="form-control required type_doc2_'+vpb_file_id+'" id="type_doc2" name="type_doc2" value="" title="File Type for photos" onchange="get_doc_type(this.value, \'' + vpb_file_id + '\')" required/><option value="0">Please Select</option>'+load_checklist('type_doc2', vpb_file_id)+'</select></td><td><span id="remove' + vpb_file_id + '"><span class="vpb_files_remove_left_inner" onclick="vpb_remove_this_file(\'' + vpb_file_id + '\',\'' + this.vpb_files[i].name + '\');">Remove</span></span></td></tr></div>';

    }
}

//Display browsed files on the screen to the user who wants to upload them

if (this.vpb_settings.vpb_form_id == "myForm") {
    $("#add_files").append(vpb_added_files_displayer);
    $("#added_class").val(new_classc);
    // load_checklist('type_doc');                  
} else if (this.vpb_settings.vpb_form_id == "myForm2") {
    $("#add_files2").append(vpb_added_files_displayer2);
    $("#added_class").val(new_classc);
    // load_checklist('type_doc2');

I used one of the codes that I search in stack overflow: How to check file MIME type with javascript before upload?

I've tried files.value='' but still the details are displayed in my table. Can anyone solve this for me? Thanks in advance.

Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46
evasim
  • 109
  • 10
  • the first files.value=' ' works perfectly but when come to the second it's not working as expected...can you show me how to do it right – evasim Mar 11 '21 at 08:34
  • files.value = null; it's not working as well – evasim Mar 11 '21 at 08:35
  • Check the value of `files`, maybe it's not the same element you've originally attached to the variable. `files.value=''` doesn't appear in your code in the post, so it's hard to say. – Teemu Mar 11 '21 at 08:45
  • i've check the value of the files it shows [object HTMLInputElement].. – evasim Mar 11 '21 at 08:52
  • Yes, but is it the same element you're looking at on the screen? – Teemu Mar 11 '21 at 08:53
  • yup its the same element n for the first files.value=' ' – evasim Mar 11 '21 at 08:54

0 Answers0