Question

7
Replies
399
Views
GR6778000 Member since 2011 3 posts
Virtusa Consulting Services Pvt.ltd
Posted: 3 years ago
Last activity: 3 years 1 month ago
Closed

Limiting the no.of files to drop in DragAndDrop control

Hi All,

I am trying to customize OOTB draganddrop control to limit the no.of files to be dropped in one go. I am able to succeed in case of Chrome Browser.

There is a separate code snippet for IE browser drag and drop feature.

Before starting the upload process i need to check the no. of files to be dropped.

I tried below in case of Chrome .

function pzHandleDrop(e){
e.stopPropagation();
e.preventDefault();

var files = e.dataTransfer.files;
var count = files.length;
pzNumberOfFilesDropped = count;
pzNumberOfFilesUploaded = 0;
var busyIndicatorSet = false
if (count != 0) {
if(count < 21){
var reader = [];
for(var i = 0 ; i < count ; i++){

if(!busyIndicatorSet){
pega.u.d.setBusyIndicator(document.getElementById("pzDragDrop"),true);
busyIndicatorSet = true;
}
if(parseInt(files[i].size) <= parseInt("<%= maxFileUploadSizeBytes %>")){
reader[i] = new FileReader();
reader[i].fileName = files[i].name;
reader[i].onload = pzUploadFile;
try{
reader[i].readAsDataURL(files[i]);
}
catch(Error){/*Firefox throws exception on reading folder*/
alert("Only file(s) upload supported");
refreshFileListSection();
}
/*Folder drop case*/
reader[i].onerror = function(){
alert("Only file(s) upload supported");
refreshFileListSection();
}
}else {
alert("File " + files[i].name + " exceeds upload size limit of <%= maxFileUploadSizeMB %> MB");
refreshFileListSection();
}

}
}else{
alert("It allows only 20 files");
refreshFileListSection();

}
}
};

I am customizing below rule.

RULE-HTML-SECTION DATA-WORKATTACH-FILE PZMULTIDRAGDROPCONTROL #20170109T024327.463 GMT

Need to understand below code snippet.

function pzInitActivexDD() {
try
{
var oDesktopInt = document.getElementById("prDesktopInt");

if (oDesktopInt != null) {
var sServerUrl = window.location.href.substr(0, window.location.href.indexOf("?pyActivity"));
oDesktopInt.initDragDropControl(sServerUrl, window, "<%= maxFileUploadSizeBytes %>", "drag_drop_target", "drag_drop_over");
eval('function oDesktopInt::UploadComplete(p1, p2, p3, p4) { dragDropEventCallback(p1, p2, p3, p4);}');

// now display correct label
initActivexDDsetLabel(1);
}
}
catch ( e ){
}
};

Any suggestions to proceed further.

Thanks in advance.

***Updated by Moderator: Marissa to update categories***

User Interface
Moderation Team has archived post
Share this page LinkedIn