Checking two arrays for matches
Presumably, once a duplicate is found you don't need to continue looping:

if (attachments.attachments[j].name === acceptedFiles[i].name) {
    duplicate = true;
}


With JavaScript, the best thing would be to wrap up your for loops in a function:

function containsDuplicate(acceptedFiles, attachments) {
    for (var i = 0; i &lt; acceptedFiles.length; i++) {
        for (var j = 0; j &lt; attachments.attachments.length; j++) {
            if (attachments.attachments[j].name === acceptedFiles[i].name) {
                return true;
            }
        }
    }
    return false;
}


As this is a problem that applies to multiple languages, look at the break keyword.