Multiple file upload with md5 check before upload

2019-03-25 13:06发布

问题:

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?

回答1:

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.