I have to download the data from a Text Box in the UI to downlaod folder in .txt format.The text file needs to have a Time Stamp and should be in this format <filename + <Time Stamp>>.txt.
I am using nodejs as the container and emberjs as the web framework. The code used for downloading the file to the download folder is
<!DOCTYPE html>
<html>
<head>
<style>
form * {
display: block;
margin: 10px;
}
</style>
<script language="Javascript" >
function download(filename, text) {
var pom = document.createElement('a');
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' +
encodeURIComponent(text));
pom.setAttribute('download', filename);
pom.style.display = 'none';
document.body.appendChild(pom);
pom.click();
document.body.removeChild(pom);
}
</script>
</head>
<body>
<form onsubmit="download(this['name'].value, this['text'].value)">
<input type="hidden" name="name" value="Output.txt" disabled="disabled">
<textarea rows=33 cols=85 name="text"></textarea>
<input type="submit" value="Save">
</form>
</body>
<button id='button'>Exeute!</button>
<script src="C:/node/jquery.min.js"></script>
<script src='clientside.js'></script>
</html>
Aucun commentaire:
Enregistrer un commentaire