使用javascript将数据保存到文本文件

使用javascript将数据保存到文本文件,javascript,html,webserver,Javascript,Html,Webserver,我找到了一个脚本,可以将文本框的内容写入文本文件,并显示下载链接 但现在我需要帮助修改此代码,以便在单击按钮后将文本文件保存到服务器中的特定位置 代码如下: <html> <head> <script type='text/javascript'>//<![CDATA[ window.onload=function(){ (function () { var textFile

我找到了一个脚本,可以将文本框的内容写入文本文件,并显示下载链接

但现在我需要帮助修改此代码,以便在单击按钮后将文本文件保存到服务器中的特定位置

代码如下:

<html>
<head>
    <script type='text/javascript'>//<![CDATA[
        window.onload=function(){
            (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) {
                        window.URL.revokeObjectURL(textFile);
                    }
                    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);
            })();
        }//]]> 
        </script>
</head>
<body>
    <textarea id="textbox">Type something here</textarea>
    <button id="create">Create file</button>
    <a download="info.txt" id="downloadlink" style="display: none">Download</a>

    <script>
    // tell the embed parent frame the height of the content
    if (window.parent && window.parent.parent){
        window.parent.parent.postMessage(["resultsFrame", {
            height: document.body.getBoundingClientRect().height,
            slug: "qm5AG"
        }], "*")
    }
    </script>
</body>
</html>

// 
在这里输入一些东西
创建文件
下载
//告诉嵌入父帧内容的高度
if(window.parent&&window.parent.parent){
window.parent.parent.postMessage([“resultsFrame”{
高度:document.body.getBoundingClientRect().height,
鼻涕虫:“qm5AG”
}], "*")
}

请告知。

您需要学习服务器端实践的后端开发。如果没有后端,客户端无法对服务器进行任何修改。(这将是一个巨大的安全漏洞!)我建议在这里学习NodeJS:


一旦您变得更加熟悉并认为您已经准备好再次接受此项目,请直接向我发送消息,我将为您指出正确的方向。

您应该将文本发送到服务器,并在后端代码中执行您想要的操作。