6

IE8 と IE9 で 'this.0.files.0' is null or not an object エラーが発生し、Chrome と Mozilla はエラーをスローしません。

$(function()) {
    var fileType = ['txt' , 'csv' ];
    $('.input_file').find('input [type = "file" ]').live('change', function (e)) {
        $this = $(this) 
        var ext = $this.val() === " " ? " " : this.value.match(/\.(.+)$/)[1];
        if($this.val()) {
            $this.parent().find('label').text.($this[0].files[0].name)  
        }
    }
}

上記のコードが javascript エラー 'this.0.files.0' is null or not an object をスローする理由がわかりません

4

2 に答える 2

11

IE < 10 は html5 fileapi をサポートしていません。つまり、ファイル名を取得するためHTMLInputElement.FileListに解析する必要はありません。HTMLInputElement.value

于 2013-04-27T18:46:49.607 に答える