Home:ALL Converter>how to create text file in any drive using javascript

how to create text file in any drive using javascript

Ask Time:2018-06-08T21:59:05         Author:Rohit Chugh

Json Formatter

<textarea id="textbox">Type something here</textarea> <button id="create">Create file</button> <a download="info.txt" id="downloadlink" style="display: none">Download</a>

(function () {
var textFile = null,
  makeTextFile = function (text) {
    var data = new Blob([text], {type: 'text/plain'});

    // If we are replacing a previously generated file we need to
    // manually revoke the object URL to avoid memory leaks.
    if (textFile !== null) {

    textFile = window.URL.createObjectURL(data);

    return textFile;

  var create = document.getElementById('create'),
    textbox = document.getElementById('textbox');

  create.addEventListener('click', function () {
    var link = document.getElementById('downloadlink');
    link.href = makeTextFile(textbox.value);
    link.style.display = 'block';
  }, false);

I have already tried this code but this code is not creating a text file. After submitting it is just showing download option but I want to store a text file in any drive

Author:Rohit Chugh,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50762322/how-to-create-text-file-in-any-drive-using-javascript