Qq.FileUploader: Cancel send

I am using the qq.FileUploader plugin.

Before sending a file, I want to know if a file with the same name is already uploaded.

I am using this code:

var uploader = new qq.FileUploader({ element: document.getElementById('file-uploader-requestDocuments'), action: '<%: Url.Action("Create", "RequestDocument") %>', params: { id: $('#RequestTempUploadFolderID').val() }, sizeLimit: 10520000, onSubmit: function (id, fileName) $('#file-uploader-requestDocuments').find('.qq-upload-file').each(function () { if ($(this).text() == fileName) { return false; return true; }); } }); 

Returning false is correct, but it does not stop sending!

How to stop file loading, and is there a better way to load an already downloaded file?

+4
source share
1 answer

how about doing this server side check? and returns the response in AJAX, for duplicate file names ?!

EDIT

if your server response:

 {"success":"false", "errorMessage":"File name is duplicate!"} 

you may have a js code:

 var uploader = new qq.FileUploader({ element: document.getElementById('file-uploader-requestDocuments'), action: '<%: Url.Action("Create", "RequestDocument") %>', params: { id: $('#RequestTempUploadFolderID').val() }, sizeLimit: 10520000, onComplete: function(id, fileName, responseJSON){ if(!responseJSON.success){alert(responseJSON.errorMessage);} } }); 
+5
source

All Articles