# Save Text File Button HTML

**URL:** <https://community.glideapps.com/t/save-text-file-button-html/51779>\
**Category:** Ask for Help\
**Created:** [October 15, 2022, 6:04am UTC](https://community.glideapps.com/t/save-text-file-button-html/51779 "2022-10-15T06:04:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yasin\_Hassanien](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/yasin_hassanien/32/9042_2.png) [@Yasin\_Hassanien](https://community.glideapps.com/u/Yasin_Hassanien)\
**Post date:** [October 15, 2022, 6:04am UTC](https://community.glideapps.com/t/save-text-file-button-html/51779/1 "2022-10-15T06:04:18Z")

</div>

Hello

Is there a way to create txt file via html to be save on the user device to download or save.

So the way is to save the user information on the device rather than using webhooks to save it on a server then redirect the user to download the exported information file text

The code below can run on any browser and without the need to have any certain library

I tried the rich text but it didn’t work.  
Any other ideas ?

````auto
<html>

<head>
<title>Javascript - Create Text file</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
}

textarea {
font-family: Arial, Helvetica, sans-serif;
padding: 5px;
}
</style>
</head>

<body>

<button type="button" id="btnSave" onclick="save()">SAVE</button>

<script>

function save() {
var data = "my information export";
var c = document.createElement("a");
c.download = "user-text.txt";

var t = new Blob([data], {
type: "text/plain"
});
c.href = window.URL.createObjectURL(t);
c.click();
}
</script>
</body>

</html>```
````

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [October 15, 2022, 6:20am UTC](https://community.glideapps.com/t/save-text-file-button-html/51779/2 "2022-10-15T06:20:12Z")

</div>

I’m not really sure I understand, but… maybe the Copy to Clipboard action might be what you are looking for?

---

<div class="post-metadata">

**Author:** ![Yasin\_Hassanien](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/yasin_hassanien/32/9042_2.png) [@Yasin\_Hassanien](https://community.glideapps.com/u/Yasin_Hassanien)\
**Post date:** [October 15, 2022, 6:49am UTC](https://community.glideapps.com/t/save-text-file-button-html/51779/3 "2022-10-15T06:49:06Z")

</div>

Basically I need to export the information in a text file and this information will be data added to the code above

So once a user click on save button it will download a .txt file

Please check this [video](https://watch.screencastify.com/v/GkGA7zAtDqOfzk1dKkHB)

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [October 15, 2022, 7:00am UTC](https://community.glideapps.com/t/save-text-file-button-html/51779/4 "2022-10-15T07:00:57Z")

</div>

So what would happen when a user clicks the button? Should a dialog open, asking them to choose a location to save the “file”?

---

<div class="post-metadata">

**Author:** ![Yasin\_Hassanien](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/yasin_hassanien/32/9042_2.png) [@Yasin\_Hassanien](https://community.glideapps.com/u/Yasin_Hassanien)\
**Post date:** [October 15, 2022, 7:13am UTC](https://community.glideapps.com/t/save-text-file-button-html/51779/5 "2022-10-15T07:13:31Z")

</div>

Yes or download directly the file

---

<div class="post-metadata">

**Author:** ![Yasin\_Hassanien](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/yasin_hassanien/32/9042_2.png) [@Yasin\_Hassanien](https://community.glideapps.com/u/Yasin_Hassanien)\
**Post date:** [October 15, 2022, 7:13am UTC](https://community.glideapps.com/t/save-text-file-button-html/51779/6 "2022-10-15T07:13:56Z")

</div>

This way to export the log in a txt file or share this txt file later
