-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathdecodeFile.html
More file actions
37 lines (34 loc) · 1.4 KB
/
Copy pathdecodeFile.html
File metadata and controls
37 lines (34 loc) · 1.4 KB
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
<!DOCTYPE html>
<html>
<body>
<input id="iptDecodeImg" type="file" accept="image/bmp,image/jpeg,image/png,image/gif">
<!--
Warning: Use a specific version in production. (e.g. https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@x.x.x/dist/dbr.min.js)
Visit https://www.dynamsoft.com/CustomerPortal/Portal/TrialLicense.aspx to get key.
-->
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode/dist/dbr.min.js" data-licensekey="t0068MgAAAAxT9peWqAbLNI2gDlg9yk8dqzhp5Me5BNCgFIg2p5X+8TPYghCr9cz6TNFlkmkpzOJelNHJaQMWGe7Bszoxoo4="></script>
<script>
let reader;
BarcodeReader.createInstance().then(r => reader = r );
document.getElementById('iptDecodeImg').addEventListener('change', function(){
if(!reader){return;}
reader.decode(this.files[0]).then(results => {
if (results.length > 0) {
console.log(results);
var txts = [];
for (var i = 0; i < results.length; ++i) {
txts.push(results[i].BarcodeText);
}
alert(txts.join("\n"));
this.value = '';
}
else
{
alert("No barcode found.");
this.value = '';
}
});
});
</script>
</body>
</html>