M
M
MGXH2020-05-12 20:52:46
JavaScript
MGXH, 2020-05-12 20:52:46

How to interact with files in JavaScript?

How to make it so that when you click on a button on the site, using JS , a new text file is created, for example test.txt , and you can change the text in it, and later also get values ​​​​from this file?

Ps - if possible, please explain in more detail how this is implemented and how to do it in my case, maybe I need to connect a new library? I have searched everywhere on the Internet, so I am writing here. I need to be sure without the intervention of php . My project is specially made statically - no databases and servers. Thanks in advance.

<!DOCTYPE html>
<html lang="en">
<head>
<script src="js/jquery.js"></script>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>

  <div class="block_content">

    <button class="btnCreateNewFile">Создать файл</button>
    
  </div>

  <script>

    $(".btnCreateNewFile").click(function()
    {
      // Здесь происходит создание файла с помощью js либо JQuery...
    });
    
  </script>
  
</body>
</html>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Froggyweb, 2020-05-12
@Froggyweb

yes, you just
don't need to write a file. We write data to Localstorage and, if necessary, throw it on the back, which validates and writes the database

X
xmoonlight, 2020-05-13
@xmoonlight

Read here.
Server - not needed at all: just set the flag you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question