Using jquery file upload synchronous not working on drop

394
January 24, 2017, at 00:17 AM

I'm using the plugin to display the image thumbnails and adding drag and drop to the page, then sending a form with other data.

When I click the button, select the images and submit the form, it display the thumbnails of the images that i have uploaded, and when the form is sended the input file show this:-

files":[{},{},{},{},{},{}] 

But when I drag and drop it still display the thumbnails of the images that i have droped, butg if i submit the form it won't work it show:-

files":[null]

This is the HTML

   <span class="btn btn-success fileinput-button">
     <i class="glyphicon glyphicon-plus"></i>
     <span>Add file...</span>
       <input id="fileupload" type="file" name="files[]" multiple>
   </span>
   <br>
   <br>
   <div id="files" class="files"></div>
   <br>

And this is the plugin's code

$(function () {
    'use strict';
    // Change this to the location of your server-side upload handler:
    $('#fileupload').fileupload({
        dataType: 'json',
        autoUpload: false,
        acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
        maxFileSize: 999000,
        replaceFileInput: false,
        // Enable image resizing, except for Android and Opera,
        // which actually support image resizing, but fail to
        // send Blob objects via XHR requests:
        disableImageResize: /Android(?!.*Chrome)|Opera/
            .test(window.navigator.userAgent),
        previewMaxWidth: 300,
        previewMaxHeight: 300,
        previewCrop: true,
        autoUpload: false,
     }).on('fileuploadadd', function (e, data) {
        data.context = $('<div/>').addClass('uploadedFile col-xs-12 col-md-6').appendTo('#files');
        $.each(data.files, function (index, file) {
            var node = $('<p/>')
                    .append($('<span/>').text(file.name))
                    .append("<span class=\"remove\"><i class=\"fa fa-times fa-2x\"></i></span>");
                    $(document).on('click','span.remove',function(){
                      $(this).parents('.uploadedFile').remove();
                    })
            if (!index) {
                node
                    .append('<br>');
            }
            node.appendTo(data.context);
        });
    })
    .prop('disabled', !$.support.fileInput)
        .parent().addClass($.support.fileInput ? undefined : 'disabled');
});

How can I make the drag and drop work?

READ ALSO
JS interconnected molecular banner

JS interconnected molecular banner

I am looking to create a homepage banner that does pretty much this: http://liveplasmacom/ (takes a bit to load) but not in flash

315
json request and respond with nodejs

json request and respond with nodejs

i am trying to send json request with nodejs but somethink is wrong here and i cant not figure outmy code is like this

437
Trouble with basic JavaScript loop

Trouble with basic JavaScript loop

I'm a newbie in JavaScript programmingAt our university we were just beginning to learn about JavaScript loops

392
Interactive webpage with JS editor

Interactive webpage with JS editor

I want to create a webpage that has a working code underneath it but interactively parts can be changed

304