我使用https://github.com/blueimp/jQuery-File-Upload上传文件。但基本上它使用原生的javascript 文件界面。我需要检查用户是否没有两次上传同一个文件。问题是文件接口确实允许访问文件路径。
那么如何以最小的系统负载比较文件? 感谢。
答案 0 :(得分:0)
您可以跟踪在数组中成功上传的文件,并在添加新文件时检查它是否已存在于数组中:
var uploadedFiles = new Array();
$(inputSelector).fileupload({
/* your configuration */
}).on('fileuploadadd', function (e, data) {
/* this is called when a file is added for upload */
var file = data.files[0];
console.log('added '+file.name+','+file.type+','+file.size);
/*
* check here if a file with the same name, type and size has been
* stored in the uploadedFiles array
*/
}).on('fileuploaddone', function (e, data) {
/* this is called when a file has been uploaded successfully */
var file = data.files[0];
console.log('uploaded'+file.name+','+file.type+','+file.size);
uploadedFiles.push(file);
});