-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselect_localfile.html
42 lines (35 loc) · 964 Bytes
/
select_localfile.html
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
<head>
<script src="jquery-1.12.0.min.js"></script>
</head>
<body>
<!-- with input that accepts one file -->
<input id="the-xml-file-input" type="file">
<script>
//this function is called when the input loads an image
function renderImage(file)
{
var reader = new FileReader();
reader.onload = function(event){
}
//when the file is read it triggers the onload event above.
reader.readAsDataURL(file);
getXmlString(file)
}
function getXmlString(file)
{
if (window.ActiveXObject) { return xml.xml; }
return new XMLSerializer().serializeToString(file);
}
$( "#the-xml-file-input" ).change(function() {
console.log("xml file has been chosen")
//grab the first file in the fileList
//in this example we are only loading one file.
console.log(this.files[0].size)
renderImage(this.files[0])
});
//alert(getXmlString(this.files[0]));
</script>
</body>
</html>