-1

I have write normal multiple file drag and drop uploader like this,

HTML:

<div class="drop-box drop-area">
    <form enctype="multipart/form-data" id="yourregularuploadformId">
        <input type="file" name="files[]" multiple="multiple" class="hidden">        
    </form>
</div>

SCRIPT:

$('.drop-area').on(
            'drop',
            function (e) {
                e.preventDefault();
                e.stopPropagation();
                if (e.originalEvent.dataTransfer) {
                    if (e.originalEvent.dataTransfer.files.length) {
                     processFileUpload(e.originalEvent.dataTransfer.files);
                    }
                }
            }
    );

function processFileUpload(droppedFiles) {
        var uploadFormData = new FormData($("#yourregularuploadformId")[0]);
        if (droppedFiles.length > 0) { 
            for (var f = 0; f < droppedFiles.length; f++) { 
                uploadFormData.append("files[]", droppedFiles[f]); 
            }
        }

$.ajax({
 url: "files.php",
            type: "POST",
            data: uploadFormData,
            cache: false,
            contentType: false,
            processData: false,
            success: function (ret) {
               alert("file uploaded !");
            },
});
}

I have to upload folder,nested folder too(dir). how to do this ? anyone got this. it can be possible. i don't need use library for do this. (It must be work for IE10)

Ashan
  • 479
  • 7
  • 28
  • Possible duplicate of [Does HTML5 allow drag-drop upload of folders or a folder tree?](http://stackoverflow.com/questions/3590058/does-html5-allow-drag-drop-upload-of-folders-or-a-folder-tree) – Alex Ivasyuv Jan 29 '16 at 09:46
  • no i don't want only chrome i need IE also. – Ashan Feb 01 '16 at 03:00

1 Answers1

1

For Chrome >= 21, it will works Chrome 21 Drag and Drop

Alex Ivasyuv
  • 8,585
  • 17
  • 72
  • 90