I have a hidden input[type=file] and a separate button which triggers click on this hidden input. How can I detect the value change in this hidden input, i.e, when the user has selected a file?
<form id="photo_upload_form" method="POST" enctype="multipart/form-data">
<button >Upload a Photo</button>
<input name="file" type="file" hidden />
</form>
Javascript:
$('#photo_upload_form button').click(function(){
$('input[type="file"]').trigger('click');
});
$('input[type="file"]').change(function(){
alert('Change !');
});
EDIT: My button click submits the form so I had to use a preventDefault !