1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>文件唯一性</title>
</head>
<body>
<input type="file">
    <script src="md5.js"></script>
    <script>
        //https://www.npmjs.com/package/js-md5
        var input  = document.querySelector('input');
        input.addEventListener('change', function () {
            var file=  this.files[0];
            var reader = new FileReader();
            reader.readAsArrayBuffer(file);
            reader.addEventListener('load',function (e) {
                var buffer = e.target.result;
                var md = md5(buffer);
                console.log(md);
            });
        });
    </script>
</body>
</html>

jsoncode
4k 声望786 粉丝

I'm jsoncode