So I'm writing some html code where someone can browse a file and save it(using some java code) in a different location under a new name. I've attempted a couple of different ways of doing this by browsing a file then reading and writing the file. However, each time I try to execute the code, it says my function has not been defined. Below is sample code, where I browse a file and then want to save the file to a new location.
The csv file would have 3 columns and 3000+ rows.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Java</title>
<script>
import java.io.File;
function ReadWriteCSVFile() {
File myFile = document.getElementById('fileinput').files;
myFile.renameTo(new File("/Directory/location/Data.csv"));
}
</script>
</head>
<body>
<form>
Select a file: <input type="file" name="img" id="fileinput">
<input type="button" id="addButton" value="Add to CSV File" onClick="ReadWriteCSVFile()" />
</form>
</body>
</html>
I can not seem to figure out why it cannot read my function for the onClick or which method would be best. Thank you for your assistance.