How to reset file input with JavaScript
Example for article at http://www.gyrocode.com/articles/how-to-reset-file-input-with-javascript/
by gyrocode
HTML
<h3><a href="http://www.gyrocode.com/articles/how-to-reset-file-input-with-javascript/">How to reset file input with JavaScript</a></h3>
<a href="http://www.gyrocode.com/articles/how-to-reset-file-input-with-javascript/">See full article on Gyrocode.com</a>
<hr><br>
<form id="frm-example" name="frm-example">
<p>
<label>Name</label><br>
<input value="John Doe" type="text">
</p>
<p>
<label>File</label><br>
<input id="example-file" type="file">
</p>
<p>
<button id="btn-example-file-reset" type="button">Reset file</button>
</p>
</form>
JavaScript
$(document).ready(function() {
$('#btn-example-file-reset').on('click', function(e) {
var $el = $('#example-file');
$el.wrap('<form>').closest('form').get(0).reset();
$el.unwrap();
});
});