<form>
<button type="submit">Submit</button>
</form>
<input type="file"/>
<script>
const form = document.querySelector('form');
const fileInput = document.querySelector('[type="file"]');
form.addEventListener('submit', e => {
e.preventDefault();
alert(fileInput.files.length ? `Name of chosen file: ${fileInput.files[0].name}` : 'Choose file');
});
</script>