ProgerXP / FileDrop

Self-contained cross-browser pure JavaScript class for Drag & Drop and AJAX (multi) file upload.
filedropjs.org
The Unlicense
264 stars 61 forks source link

Files of the same name are ignored when uploading directories #76

Closed yanmingsohu closed 4 years ago

yanmingsohu commented 4 years ago

Use 'webkitdirectory' on INPUT tag Files with the same name in different directories will be ignored.

I try to modify (filedrop.js::1520) Use FFFIX: indicate

        for (var i = 0; i < list.length; i++) {
          var navFile = list[i]; 
          var file = new global.File(navFile)
          //FFFIX: May full path with name
          var _name = navFile.webkitRelativePath || file.name

          // Safari Windows adds first file several times so skip them.
          // ...while iOS Safari adds files under the same name - image.jpg (#30).
          if (!names[_name] || file.name == 'image.jpg') {
            //FFFIX: if only use 'name', same file name in different directories will be ignored
            names[_name] = true
            file.setNativeEntry(entries[i])
            global.callAllOfObject(self, 'fileSetup', file)

            // Directories have zero size but in Chrome they are useful
            // since you can access underlying DIrectoryEntry and read files.
            if (file.size > 0 || file.nativeEntry) {
              result.push(file)
            }
          }
        }
ProgerXP commented 4 years ago

Thanks for your feedback. Does this version work for you? filedrop.js.zip

yanmingsohu commented 4 years ago

Yes! cool