Question

Part of my code:

$("input[name='image']", selector_id).each(function(index) {
    var this_selector = $(this),
        this_file = this_selector[0].files[0], // ERROR LINE
        this_image;

    if (this_file) {
        this_image = new FormData();
        this_image.append('image', this_file);  
        images.push(this_image);
    }
}); 

I'm using jQuery to upload images via AJAX and in IE<10 I get the error: "Unable to get property '0' of undefined or null reference", and it's refering to the line "ERROR LINE" above. Also, I suspect FormData is also not working in IE<10.

How can I make this work in IE8-9?

Edit - Let me rephrase my question: I know some of these things don't work in IE<10. What are the common workarounds/methods for making it work in IE8?

Was it helpful?

Solution

The only workarounds to this problem for browsers that don't support FormData is to either submit to a hidden iframe, or to use flash. There are many plugins out there that do this for you, or you can roll your own because it really isn't that difficult to implement (it doesn't even require javascript.)

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