Question

I am using the following code to effect an iframe that allows an ajax file upload on submit of the form without refresh.

This works as expected

window.onload=init; 
function init() {
document.getElementById('form').onsubmit=function() {
    document.getElementById('form').target = 'iframe'; 
            }
        }

What i would like to do is the same thing but 'onchange' of the file field input, i.e. when the user has chosen a file, to autmatically trigger the init() function and thus upload the file. I have tried with this code:

document.getElementById('file').onchange=function(){...

This doesn't work, and i'm completely stuck. Any ideas?

Many thanks

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top