Below is part of the jquery code I have which displays the file input and a \"Clear File\" button.
var $imagefile = $(\'\').attr({
type: \
This is the method I like to use as well but I believe you need to add the bool true parameter to the clone method in order for any events to remain attached with the new object and you need to clear the contents.
var input = $("#fileInput");
function clearInput() {
input = input.val('').clone(true);
};
https://api.jquery.com/clone/