0

我試圖使用文件傳輸插件上傳手機隙文件,但FILE_URI返回斑點
blob:http%3A//localhost%3A65304/506be833-4afb-42a4-beed-01e43bc9cd64
然後我用下面的代碼來驗證它的文件路徑和返回錯誤代碼5.上傳中的PhoneGap /科爾多瓦任何類型的文件

jQuery代碼:

window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + snapSrc, gotFile, fail); 

function fail(e) { 
    console.log("FileSystem Error"); 
    console.dir(e); 
} 

function gotFile(fileEntry) { 

    fileEntry.file(function(file) { 
     var s = ""; 
     s += "<b>name:</b> " + file.name + "<br/>"; 
     s += "<b>localURL:</b> " + file.localURL + "<br/>"; 
     s += "<b>type:</b> " + file.type + "<br/>";   
     document.querySelector("#status").innerHTML = s; 
     console.dir(file); 
    }); 
} 
  1. 如何找到的名稱和文件的類型。
  2. 如何解決錯誤代碼5

回答

0

這個問題解決了,它在真實設備中完美運行,我認爲問題在於intel xdk模擬器。

0

您正在用resolveLocalFileSystemURL這是不正確的方法使用resolveLocalFileSystemURI代替resolveLocalFileSystemURL。 你可以嘗試下面的方法,希望它能幫助你。

window.resolveLocalFileSystemURI(cordova.file.applicationDirectory + snapSrc, onSuccess, fail); 

function onSuccess(fileEntry) { 
    console.log(fileEntry.name); 
} 

function fail(error) { 
    console.log(error.code); 
} 

讓我知道,如果它不工作。

+0

resolveLocalFileSystemURI已棄用。請改爲調用resolveLocalFileSystemURL。 – veeran

+0

我使用intel xdk,它說「resolveLocalFileSystemURI已被棄用,請調用resolveLocalFileSystemURL」。 – veeran

相關問題