我想將文件存儲到本地計算機。使用JavaScript將文件存儲到本地計算機(正在下載)
對於HTML5,我們可以使用cookies
和local storage
將數據存儲到本地計算機。 本地存儲使用key-value
對(json
)來存儲數據。 但是,我想要以不同的格式保存數據,例如以XML格式保存。
在諸如convertonlinefree.com之類的網站上,當文件被轉換時,文件將自動開始下載。
所以,我正在考慮一種方法來做到這一點: 當用戶點擊一個按鈕時,XML文件會自動下載。這可能嗎?如果是這樣,我該怎麼做?
這裏已經討論過了:http://stackoverflow.com/questions/19744155/writing-file-to-desktop-using-html5-filesystem-api – 2014-09-02 20:24:16
使用http://danml.com/js/download。 js,它只是下載(strXmlData,「myxmlfile1.xml」,「text/xml」);單獨使用dataURL可能不會觸發XML的下載,因爲一些瀏覽器顯示文檔... – dandavis 2014-09-02 20:31:26
謝謝,我在討論中找到這個:http://stackoverflow.com/questions/19744155/writing-file-to-desktop-using- html5-filesystem-api – yongnan 2014-09-02 20:32:47