-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.js
26 lines (21 loc) · 978 Bytes
/
code.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
let saveFile = () => {
// Get the data from each element on the form.
const name = document.getElementById("txtName");
const email = document.getElementById("txtEmail");
const image = document.getElementById('imageInput');
// This variable stores all the data.
let data = "\r Name: " + name.value + " \r\n " + "Email: " + email.value + " \r\n " + "Image" + image.value + "\r\n" ;
console.log(data); //printing form data into the console
// Convert the text to BLOB.
const textToBLOB = new Blob([data], { type: "text/plain" });
let newLink = document.createElement("a");
newLink.download = new Date();
if (window.webkitURL != null) {
newLink.href = window.webkitURL.createObjectURL(textToBLOB);
} else {
newLink.href = window.URL.createObjectURL(textToBLOB);
newLink.style.display = "none";
document.body.appendChild(newLink);
}
newLink.click();
};