Posted By

FatFolderDesigner on 03/19/11



Versions (?)

valums AJAX file upload single item fix

 / Published in: JavaScript


There's a small error in valums ajax upload script ( When set to not allow multiple uploads droping multiple files on the script will still upload them all at once. The below is a fix I came up with, replace line 574 with the for if statment

  1. var key; var cnt=-2; // Not sure why it's always adding 2 but it _always_ is.
  2. for (key in e.dataTransfer.files) {
  3. cnt++;
  4. }
  5. if(self._options.multiple==false && cnt>1){
  6. self._options.showMessage('You may only upload 1 file at the site, please deselect '+(cnt-1)+' images and try again.');
  7. }else{
  8. self._uploadFileList(e.dataTransfer.files);
  9. }

Report this snippet  

You need to login to post a comment.