我正在使用DropzoneJS作为.net核心应用程序的一部分来促进文件(图像)的上传。我希望能够将文件的尺寸(宽度和高度)发送到.net控制器。但是,在调整文件大小之后,我还无法弄清楚如何获取媒体文件的尺寸。
这是js声明:
product_media_dropzode_ctrl = new Dropzone("#product_form_ctrl", {
paramName: "file",
maxFilesize: 3,
maxFiles: 10,
acceptedFiles: ".jpeg,.jpg,.png,.gif",
autoProcessQueue: true,
uploadMultiple: false,
parallelUploads: 100,
resizeWidth: 1920,
resizeHeight: 1080,
resizeMimeType: 'image/jpeg',
resizeQuality: 1.0,
resizeMethod: 'crop',
accept: function (file, done) {
if (UploadedNumberFiles() > maxNumberOfMediaFile) {
done("The maximum number of files has been reached.");
}
else {
done();
}
},
init: function () {
this.on("thumbnail", function (file, dataUrl) {
**console.log("widthXheight:" + file.width + "X" + file.height);**
$('#product_width_hidden_ctrl').val(file.width);
$('#product_height_hidden_ctrl').val(file.height);
})
this.on("success", function (file, response) {
HandleUploadSuccess(response);
});
this.on('error', function (file, response) {
HandleUploadError(response);
});
},
});
}
如果我上传文件4151X2000,则文件大小将调整为1920X1080,但是下面的行将显示4151X2000,而不是1920X1080。如果我上传文件1800X1200,则显示1800X1200,而不是1800X1080,这是文件大小调整后的尺寸
**console.log("widthXheight:" + file.width + "X" + file.height);**
在调整图像大小之后以及将文件提交到服务器之前,是否可以捕获文件尺寸?