Dropzone getAcceptedFiles () производит [объектный файл] вместо файла - PullRequest
0 голосов
/ 07 октября 2019

Я добавил следующую функцию, чтобы попытаться получить массив имен файлов, помещенных в зону перетаскивания:

function toggleUploadButton() {
    console.log(myDropzone.getAcceptedFiles() + "Accepted Files"); // []
    console.log(myDropzone.getQueuedFiles() + "Queued Files");  // []
    console.log(myDropzone.getRejectedFiles() + "Rejected Files");  // [File] <- same as above
}

Однако вывод в console.log приводит к:

[object File],[object File],

Вместо самого имени файла.

По сути, я пытаюсь получить информацию о файле, чтобы я мог отправить ее через другую часть моегокод через ajax для загрузки.

Будет ли [object File] переносить всю основную информацию о файле для загрузки, или его нужно структурировать по-другому?

var myDropzone = new Dropzone("#myDropzone", {
    //$('#myDropzone').dropzone ({
    //Dropzone.options.myDropzone= {
        url: 'php/quoteSendTest.php',
        autoProcessQueue: false,
        paramName: "file",
        uploadMultiple: true,
        parallelUploads: 5,
        maxFiles: 5,
        maxFilesize: 25,
        acceptedFiles: 'image/*',
        addRemoveLinks: true,
        dictFileTooBig: 'File is larger than 25MB',
        init: function() {
            dzClosure = this; // Makes sure that 'this' is understood inside the functions below.

            // for Dropzone to process the queue (instead of default form behavior):
            document.getElementById("submit-all").addEventListener("click", function(e) {
                // Make sure that the form isn't actually being sent.
                console.log("Something should be showing for eventListener");
                //e.preventDefault();
                e.stopPropagation();
                dzClosure.processQueue();
            });

            this.on("addedfile", function(file) {
                /* Maybe display some more file information on your page */
                dragFileName = file.name;
                var dragFileSize = file.size;
                var count = myDropzone.files.length;
                console.log('File added - ' + file.name + ' - Size - ' + file.size);
                //console.log(dragFileName[]);
                console.log(count + " is the length");
                //toggleUploadButton();
                setTimeout(function () {
                    toggleUploadButton();
                }, 10);
            });

            //send all the form data along with the files:
            this.on("sendingmultiple", function(data, xhr, formData) {
                formData.append("firstname", jQuery("#firstname").val());
                formData.append("lastname", jQuery("#lastname").val());
            });
        }
    });
    function toggleUploadButton() {
        console.log(myDropzone.getAcceptedFiles() + "Accepted Files"); // []
        console.log(myDropzone.getQueuedFiles() + "Queued Files");  // []
        console.log(myDropzone.getRejectedFiles() + "Rejected Files");  // [File] <- same as above
    }
...