JSFiddle - React, Tailwind, and code Playground
by Harris Brakmic
HTML
<script src="https://gist.githubusercontent.com/ZiTAL/2d580021a24af7aede12/raw/8356279ac76897fbf55e77564c6c3332c3f8954a/md5.js"></script>
<form action="" method="post">
<input type="file" name="file" id="fileToUpload" multiple="multiple"/>
<input type="submit" />
</form>
JavaScript
// twitter.com/zital
var fileToUpload = document.getElementById('fileToUpload');
fileToUpload.onchange = function(e)
{
var files = e.target.files;
for(var i in files)
{
if(typeof files[i]['lastModified']!='undefined')
{
(function(file)
{
// hash md5
var reader = new FileReader();
reader.onload = function(event)
{
var binary = event.target.result;
var hash = md5(binary);
console.log("name: "+file['name']);
console.log("hash: "+hash);
};
reader.readAsBinaryString(file);
})(files[i]);
}
}
};