在上传之前用md5检查多文件上传 [英] Multiple file upload with md5 check before upload

查看:146
本文介绍了在上传之前用md5检查多文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个网页,我需要一个多文件上传的实现,可以在将文件上传到服务器之前对其进行散列。

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.

这个想法是,可以上传已经存在或不存在于服务器上的文件。为了节省带宽,我想在将文件上传到服务器之前对其进行散列处理,通过POST发送散列,并且只有在服务器响应它没有包含这个散列的文件时才进行上传。

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.

有没有免费的基于Flash的实现(我想JavaScript将无法加载文件并对其进行哈希)可能适合我?

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?

推荐答案

您可以在Javascript中读取文件,在HTML5的FileReader API会为你做这项工作。

You can read files in Javascript, FileReader API in HTML5 will do the job for you.

接下来,馈以base64串入 b64_md5()功能这个库提供:
http://pajhome.org.uk/crypt/md5/instructions.html

Next, feed the base64 string into b64_md5() function provided by this library: http://pajhome.org.uk/crypt/md5/instructions.html

请注意,它可能是如果文件太大,耗费时间。您可能还需要WebWorkers来完成协商背景。

Note that it could be time consuming if the file is too big. You might also need WebWorkers to do the conculation background.

这篇关于在上传之前用md5检查多文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆