Javascript 如何让这个文件上传jQuery代码在IE8中工作?
我的部分代码:Javascript 如何让这个文件上传jQuery代码在IE8中工作?,javascript,jquery,internet-explorer,internet-explorer-8,polyfills,Javascript,Jquery,Internet Explorer,Internet Explorer 8,Polyfills,我的部分代码: $("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();
$("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);
}
});
我使用jQuery通过AJAX上传图像,在IE中,对于不支持FormData的浏览器,解决这个问题的唯一方法是提交到隐藏的iframe,或者使用flash。有很多插件可以为您实现这一点,或者您也可以使用自己的插件,因为它其实并不难实现(甚至不需要javascript)。请参见:-建议使用“jquery.form”,因为旧浏览器不支持FormData,也不支持类似的功能。在这种情况下必须使用iframe。