<form id="uploadForm" method="post" enctype="multipart/form-data">
<input type="file" id="userPhotoInput" name="files[]">
</form>
<script type="text/javascript">
$(document).ready(function() {
$('#userPhotoInput').on('change', function() { this.form.submit(); });
});
</script>
var uploadForm = $('#uploadForm');
$('#userPhotoInput').on('change', function () {
uploadForm.submit();
});