[javascript] How do I auto-submit an upload form when a file is selected?

JavaScript with onchange event:

_x000D_
_x000D_
<form action="upload.php" method="post" enctype="multipart/form-data">_x000D_
     <input type="file" name="filename" onchange="javascript:this.form.submit();">_x000D_
</form>
_x000D_
_x000D_
_x000D_

jQuery .change() and .submit():

_x000D_
_x000D_
$('#fileInput').change(function() {_x000D_
  $('#myForm').submit();_x000D_
});
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>_x000D_
<form action="upload.php" id="myForm">_x000D_
     <input type="file" id="fileInput">_x000D_
</form>
_x000D_
_x000D_
_x000D_