The event is clickfired before the value is set. Rather check it out during the event change.
$('#image-file').change(function() {
});
Or, better, when submitting the form, because it changewill not be launched when the user has not selected anything, and the field itself was already empty.
$('#form').submit(function() {
});
source
share