发送事件时宽度和高度“未定义”

时间:2015-07-23 02:25:00

标签: javascript jquery symfony-forms dropzone.js

我正在尝试在发送事件期间将文件的宽度和高度附加到我的formData,但它始终显示为“未定义”:

$(document).ready(function() {

        Dropzone.options.dropZone = {
            paramName: "file", // The name that will be used to transfer the file
            maxFilesize: 64, // MB
            dictDefaultMessage: '<i class="fa fa-cloud-upload"></i> \
                 <span class="main-text"><b>Drop Files</b> to upload</span> <br /> \
                 <span class="sub-text">(or click, max file size: 64 MB)</span> \
                ',
            dictResponseError: 'Server not Configured',
            init: function () {
                this.on("sending", function (file, xhr, formData) {
                    // Will send the filesize along with the file as POST data.
                    console.log(file.width); //display "undefined"
                    formData.append("width", file.width);
                    formData.append("height", file.height);
                });

            }
        }
    });

如何访问文件的尺寸并将其发送到我的控制器(Symfony)?

0 个答案:

没有答案