0
我正在構建一個Android應用程序使用HTML5 +科爾多瓦在IntelXDK。我正在使用HTML5下載文件,如下所示。獲取Android應用程序下載的文件路徑
<script type='text/javascript'>
function saveTextAsFile()
{
var textToWrite = "This Is The Inner Text Of File.";
var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'});
var fileNameToSaveAs = "MyFileName.txt";
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Download File";
if (window.webkitURL != null)
{
// Chrome allows the link to be clicked
// without actually adding it to the DOM.
downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
}
else
{
// Firefox requires the link to be added to the DOM
// before it can be clicked.
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
downloadLink.onclick = destroyClickedElement;
downloadLink.style.display = "none";
document.body.appendChild(downloadLink);
}
downloadLink.click();
// alert(filesavedat); // <<<--- Need the downloaded file path here
}
</script>
我不知道天氣用戶只有內存或SD卡,也不知道他/她的默認下載文件夾。我希望在用戶設備在我的JavaScript代碼(變量)中下載後保存該文件的路徑。這是否可能?如果是,那麼如何?