-1

部分:如何讓這個文件上傳jQuery代碼在IE8中工作?我的代碼

$("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 < 10張我的錯誤:「無法獲得的未定義或爲空引用屬性‘0’」,並它指的是上面的「錯誤行」一行。另外,我懷疑FormData在IE中也不工作< 10.

我該如何在IE8-9中完成這項工作?

編輯 - 讓我改一下我的問題:我知道對這些事情並不在IE工作< 10.什麼是使得它在IE8的工作共同解決方法/方法?

+0

看到這個:http:// stackoverflow。 com/questions/10852446/fallback-for-formdata-in-ie-8-9 - 建議「jquery.form」,因爲舊的瀏覽器不支持FormData並且沒有任何相似之處。在這種情況下,你必須使用iframe。 – Frogmouth

+0

可能的重複[如何可以與jQuery異步上傳文件?](http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery) –

+0

FormData不支持 Satpal

回答

1

對於不支持FormData的瀏覽器,此問題的唯一解決方法是提交到隱藏的iframe或使用flash。有很多插件可以爲你做這件事,或者你可以自己推出,因爲它實際上並不難實現(它甚至不需要javascript)。

相關問題