10

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?

Rytis
  • 1,447
  • 1
  • 19
  • 38
  • 1
    Interesting request, but I can't see anything in the direction. Here is a related feature request in swfupload: http://code.google.com/p/swfupload/issues/detail?id=287 you could consider opening a feature request yourself, or add it yourself to SWFUpload or a similar implementation if you speak Flash. It should be relatively easy to have Flash pass the MD5 value to a Javascript callback (I think there already is a `onselect` callback), and to do the rest via a Ajax request – Pekka Nov 15 '10 at 20:34
  • Might be of help: http://stackoverflow.com/questions/768268/how-to-calculate-md5-hash-of-a-file-using-javascript –  Nov 24 '10 at 06:10

1 Answers1

3

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.

timdream
  • 5,914
  • 5
  • 21
  • 24