chromeブラウザでHTML5のfile apiを使用してもファイル出力ができず困っております。
動作環境は、Macです。
ウェブサーバをpythonで起動し、localhostアクセスして動作させています。
(python 3.6 :実行コマンド python -m http.server 8000)
HTMLのoutputlogボタンを押した後、outputLogFile()がコールされ、
エラーにはならず、onwriteendコールバックが呼ばれているため、
成功していると思っておりますが、実際にファイル出力ができていません。
何かやり方がまずいのでしょうか?
javascript
1 function outputLogFile() { 2 function error(e) { 3 alert("ERR!: " + e.name); 4 } 5 6 function writeFile(fs) { 7 fs.root.getFile('/log.txt', {create: true}, function(fileEntry) { 8 fileEntry.createWriter(function(fileWriter) { 9 fileWriter.onwriteend = function(e) { 10 console.log('Write completed.'); 11 }; 12 13 fileWriter.onerror = function(e) { 14 console.log('Write failed: ' + e.toString()); 15 }; 16 17 var output = new Blob(["this is log data"], {type: "text/plain"}); 18 fileWriter.write(output); 19 }, error); 20 }, error); 21 } 22 window.webkitRequestFileSystem(window.TEMPORARY, 1024*1024, writeFile, error); 23 }
HTML
1<HTML> 2<head></head> 3<body> 4 <input type="button" value="outputlog" onclick="outputLogFile()" > 5</body> 6</HTML>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/03/20 06:14
2018/03/20 06:17
2018/03/20 07:58