2

次のコードスニペットを使用して、JavaScriptでファイルを読み取ります。

if(window.FileReader && filelist.length > 0) {
    var reader = new FileReader();
    reader.onload = reader.onloadend=function(event){
        self._ogrUpload(self, event);
    };
    reader.readAsText(filelist[i]);
    console.log(filelist[i]);
}

これはChromeでは機能しますが、SafariV6.0では機能しません。

Safariでは、アップロードは機能しているように見えますが、関数_orgUpload()は呼び出されません。だから私はこれを次のように置き換えました:

reader.onload = function(event) { alert("TEST");};

これもうまくいきませんでした。FileReaderは実際にSafari6.0で動作しますか?コンソールにスローされたエラーが表示されないため。

4

1 に答える 1

0

これを試して、どのような機能がサポートされているかを確認してください

function checkFileApi(){
    var debuggers="<h4>browser supports following</h4>"
    if (window.File) debuggers+="Supports File api<br>"
    if (window.FileReader) debuggers+="Supports FileReader api<br>"
    if(window.FileList) debuggers+="Supports FileList api<br>"
    if(window.Blob) debuggers+="Supports Blob api<br>"

    console.log(debuggers)
}

checkFileApi()
于 2012-11-29T15:01:53.167 に答える