Reputation: 1445
I am building a webpage for which I need a multi-file upload implementation that can hash a file before uploading it to the server.
The idea is that users can upload files that may or may not exist on the server already. To save bandwidth I want to hash the file before uploading it to the server, send the hash via POST, and only proceed with upload if the server responds that it does not have a file with this hash.
Are there any free Flash-based implementations (I suppose that JavaScript won't be able to load the file and hash it) that may work for me?
Upvotes: 10
Views: 3025
Reputation: 5922
You can read files in Javascript, FileReader API in HTML5 will do the job for you.
Next, feed the base64 string into b64_md5()
function provided by this library:
http://pajhome.org.uk/crypt/md5/instructions.html
Note that it could be time consuming if the file is too big. You might also need WebWorkers to do the conculation background.
Upvotes: 3