0

我正在上传多张图片,但在上传之前,我想在客户端将它们全部压缩,然后想上传到服务器,因为我正在使用 dropzone.js(以编程方式),如下所示,但该功能resizeQuality不起作用。所有图片均以原始尺寸上传。

我哪里错了?欢迎任何建议...

html:

<form class="dropzone" id="myDropzone" method='POST' action='' enctype='multipart/form-data'>
<div class="fallback"> <!-- this is the fallback if JS isn't working -->
    <label>
    <input name="file" type="file" multiple />
    knkjbnkhbkb </label>
</div>
<div class="dropzone-previews"></div>
</form>

jQuery:

    Dropzone.autoDiscover = false;
    Dropzone.options.myDropzone = {
        url: "/dashboard/{{name}}/{{name_product_type.type_product|urlencode}}/{{abc}}",
        autoProcessQueue: false,
        uploadMultiple: true,
        parallelUploads: 30,
        resizeQuality: 0.6,   <----- NOT WORKING
        maxFiles: 100,
        acceptedFiles: "image/*",

        init: function () {

            var submitButton = document.querySelector("#postbtn");
            var wrapperThis = this;

            submitButton.addEventListener("click", function () {
                wrapperThis.processQueue();
            });

            this.on("addedfile", function (file) {

                // Create the remove button
                var removeButton = Dropzone.createElement("<button class='btn btn-lg dark'>Remove File</button>");

                // Listen to the click event
                removeButton.addEventListener("click", function (e) {
                    // Make sure the button click doesn't submit the form:
                    e.preventDefault();
                    e.stopPropagation();

                    // Remove the file preview.
                    wrapperThis.removeFile(file);
                    // If you want to the delete the file on the server as well,
                    // you can do the AJAX request here.
                });

                // Add the button to the file preview element.
                file.previewElement.appendChild(removeButton);
            });

            //this.on('sendingmultiple', function (data, xhr, formData) {
              //  formData.append("Username", $("#Username").val());
            //});
        }
    };

需要进行哪些更正?

4

0 回答 0