Reputation: 576
I am building an image-upload feature into a web application and am using the following event handler:
$('input:file').change(function(){
//handle input change
});
I have discovered that the handler is not called if I try to upload the same image twice, which makes sense because technically the input is not changing. But I am wondering, what needs to happen in order for the change to be triggered? Here are some examples of what I am looking for:
Which of these would cause a file to be received as a changed file? Or are there other scenarios as well?
Upvotes: 2
Views: 988
Reputation: 20626
Input type - File :
The onchange event is fired when the contents have changed. If the user types the path (does not use the Browse button) in Internet Explorer, then the onchange event is fired only when the element loses the focus. Therefore use the onpropertychange event to detect the modification in Internet Explorer.
Fires when the contents of the object or selection have changed.
My test results :
So, moral of the story is, by content change they mean filename change.
Upvotes: 5