I would like to specify my .txt file name when saving it with the FileSaver tool available here:
https://github.com/eligrey/FileSaver.js/
As far as I dug down in the web, I found, that in default there is no option for saving it under the specified filename like pointed here:
Is there any way to specify a suggested filename when using data: URI?
Save file Javascript with file name
Can't specific file name with FileSaver.js
there is no reliable way to do this.
However I found something, which would entirely satisfy me. The page is called: FileSaver.js demo
https://eligrey.com/demos/FileSaver.js/
which includes several options of saving files with specified filenames, while also the .txt file.
It means, that apparently the option exist, since they have managed with it.
After I have inspected their website, I tried to replicate the JavaScript code, they used. My piece of code looks like this now:
<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/eligrey/FileSaver.js/c3e4a45021f205a790a2699f4af7a5b85fb63e09/demo/demo.css"/>
<script src="../js/FileSaver.js"></script>
<script async="" src="https://cdn.rawgit.com/eligrey/Blob.js/0cef2746414269b16834878a8abc52eb9d53e6bd/Blob.js"/>
<script async="" src="https://cdn.rawgit.com/eligrey/canvas-toBlob.js/f1a01896135ab378aa5c0118eadd81da55e698d8/canvas-toBlob.js"/>
<script async="" src="https://cdn.rawgit.com/eligrey/FileSaver.js/5ed507ef8aa53d8ecfea96d96bc7214cd2476fd2/FileSaver.min.js"/>
<script async="" src="https://cdn.rawgit.com/eligrey/FileSaver.js/5ed507ef8aa53d8ecfea96d96bc7214cd2476fd2/demo/demo.min.js"/>
<textarea class="input" id="text" placeholder="Once upon a time..."/></textarea>
<form id="text-options">
<label>Filename: <input type="text" class="filename" id="text-filename" placeholder="a plain document"/>.txt</label>
<input type="submit" value="Save"/>
</form>
but unfortunately, it doesn't work as expected.
When I click the "Save" button it just refreshes the page instead of saving the relevant files with the <textarea>
content.
Is there any option to fix it at some point?