I dont see any issue on your example with firefox or chrome (and not with IE11). Look at http://jsfiddle.net/Pd465/1/
I remember a similar issue on older IE versions. The solution was to change the onchange to onclick and set a timeout with 0ms. Even that it's looking a little hacky it worked and the timeout just waited for the open-dialog to close. (Note: this must be done by browser-detection since it won't work on ff or chrome)
A pure javascript solution would be (for jQuery solution look at the last edit):
function submitForm(){
window.setTimeout(
function(){
//will be executed when the dialog is closed -> submit your form
//you might want to check if a file is selected here since the onclick will be triggered also in case of pressing 'cancel'-button
document.getElementById('submitForm').submit();
}, 0
);
}
....
<form id="submitForm" action="upload.php" method="post" enctype="multipart/form-data">
<input type="image" id="IMG_1" src="<?php echo $result['profile_picture']?>" alt="">
<input type="file" onclick='submitForm();' id="my_file" style="display: none;" />
</form>
EDIT :
I found the article again where i got this solution from: Jquery: change event to input file on IE
EDIT :
I did not see this is not only javascript but also jQuery tagged... so I think you can overtake the solution from @Clint Tseng of the article i mentioned above. His solution:
var $input = $('#your-file-input-element');
var someFunction = function()
{
// what you actually want to do
};
if ($.browser.msie)
{
// IE suspends timeouts until after the file dialog closes
$input.click(function(event)
{
setTimeout(function()
{
if($input.val().length > 0) {
someFunction();
}
}, 0);
});
}
else
{
// All other browsers behave
$input.change(someFunction);
}