I am trying to check if a file from a multiple upload exists in the path already, if so i want to chuck out a validation error. Its the else if part that is not working. The number directory gets created in the ajax controller server side, but i want to do a check before they upload further files with the same name to that directory. Is this possible? What am i doing wrong here?
function makeProgress(number){   
          var url = getRelativeURL("web/fileUpload");   
          var formData = new FormData();
          formData.append('number', number);
          fls = document.getElementById("attachmentFileUploadInput").files; //number of files... 
          console.log(fls);
          var location = "C:/temp/" + number + "/";
          console.log(location);
          // maximum number of files at a time is 10
          if(fls.length >= 11){
              FileUploadLengthVisible(true);
              return false;
          }
          var j;
          for(j=0;j<fls.length;j++){
              if (fls[j].size > 5000000) //5MB size per file
            {
                  FileUploadSizeVisible(true);
                  return false;
            }
              else if (location + fls[j] == true)
        {
                  alert("file exists");
                  return false;
        }
              else
                  {
              formData.append('files[]', fls[j]);  //note files[] not files
              $.ajax({
                  url : url,
                  data : formData,
                  processData : false,
                  cache: false,
                  contentType: false,
                  type : 'POST',
                  success : function(data) {
                   FileUploadVisible(true);
                   $('#attachmentModal').modal('hide')
                   $(':input','#attachmentModal').val("");
                    $("#pbarmain").hide();
                    $("#pbar").hide();
                    $("#actionPlanDiv").hide();
                    setObjectEnabled('#Upload',false);
                  },
                  error : function(err) {
                      FileUploadErrorVisible(true);
                  }
             });
              console.log('loop each file working');
          }
          }
          console.log("form data " + formData);
            }
 
    