仅将文件数据从dropzone添加到formData

时间:2018-12-05 19:33:29

标签: javascript jquery file dropzone.js

我使用以下脚本从dropzone捕获了文件:

var formData = new FormData();
$('[name="' + form + '"] *').filter('div.dropzone').each(function() {
    var DropFile = $(this)[0].dropzone.getAcceptedFiles();
    for (Nof in DropFile) {
        var file = DropFile[Nof]; //i need clean this object
        var name = DropFile[Nof].name;
        formData.append(name, file);
    }
});

Contenido de DropFile[Nof]

File(8984) {upload: {…}, status: "queued", previewElement: div.dz-preview.dz-processing.dz-success.dz-complete.dz-image-preview, previewTemplate: div.dz-preview.dz-processing.dz-success.dz-complete.dz-image-preview, accepted: true, …}
accepted: true
height: 412
lastModified: 1533592107024
lastModifiedDate: Mon Aug 06 2018 16:48:27 GMT-0500 (hora estándar oriental) {}
name: "prueba.jpg"
previewElement: div.dz-preview.dz-processing.dz-success.dz-complete.dz-image-preview
previewTemplate: div.dz-preview.dz-processing.dz-success.dz-complete.dz-image-preview
size: 8984
status: "queued"
type: "image/jpeg"
upload: {progress: 0, total: 8984, bytesSent: 0}
webkitRelativePath: ""
width: 694
__proto__: File

这是文件input中的正常内容(不是dropzone):

File(8984) {name: "prueba.jpg", lastModified: 1533592107024, lastModifiedDate: Mon Aug 06 2018 16:48:27 GMT-0500 (hora estándar oriental), webkitRelativePath: "", size: 8984, …}
lastModified: 1533592107024
lastModifiedDate: Mon Aug 06 2018 16:48:27 GMT-0500 (hora estándar oriental) {}
name: "prueba.jpg"
size: 8984
type: "image/jpeg"
webkitRelativePath: ""
__proto__: File

但是问题是DropFile[Nof]是一个文件中包含大量信息的对象,我该如何清除它以防止出现此错误:

Error ouput: Maximum call stack size exceeded error

当我尝试让所有递归对象在javascript上运行时,浏览器都会显示它。

0 个答案:

没有答案