-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.html
42 lines (37 loc) · 988 Bytes
/
test.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 lang='en-US'>
<head>
<meta charset='en-US'>
<title>Test</title>
</head>
<body>
<script type='text/javascript'>
var buffer=null;
function captureFile(event) {
event.preventDefault()
console.log("in capture"+event.target.files[0]);
const file = event.target.files[0]
console.log(file);
const reader = new FileReader()
reader.readAsArrayBuffer(file)
reader.onloadend = async () => {
var Buffer = require('buffer').Buffer;
buffer= new Buffer(reader.result);
console.log('buffer', buffer)
await ipfs.files.add(buffer, (err, result) => {
if(err)
{
console.log('yolo'+err);}
temp:result[0].hash;
console.log(temp);
});
}
}
</script>
<div id='outer'>
<div id='inner'>
<input type="file" onChange=captureFile(event) id="ctrl" webkitdirectory directory multiple/>
</div>
</div>
</body>
</html>