【发布时间】:2023-01-20 02:07:56
【问题描述】:
我有一个页面,我可以在其中使用 Dropzone.js 成功上传多张图片,但我希望访问者在上传前根据自己的选择裁剪它们。我能够单独使用 cropper.js 但无法将它们集成在一起。
这是我的原始工作代码摘录。
HTML:
<div class="dropzone dz-clickable" id="myDrop">
<div class="dz-default dz-message" data-dz-message="">
<span>No Photo Selected</span>
</div>
</div>
<div id="add_file">POST</div>
记者:
//Dropzone script
Dropzone.autoDiscover = false;
var myDropzone = new Dropzone("div#myDrop",
{
paramName: "__files", // The name that will be used to transfer the file
addRemoveLinks: true,
uploadMultiple: true,
withCredentials: true,
autoProcessQueue: false,
parallelUploads: 5,
maxFiles: 5,
maxFilesize: 20, // MB
acceptedFiles: ".png, .jpeg, .jpg, .gif, .JPG, .jfif",
url: "sdk/process-upload.php",
capture: "camera",
init: function () {
this.on('sending', function(file, xhr, formData) {
// Append all form inputs to the formData Dropzone will POST. This data is taken from a form
var l = document.getElementById("locationval").value;
formData.append('location', l);
var x = document.getElementById("postmaker").innerText;
formData.append('pdata', x);
});
}
});
/* Add Files Script*/
myDropzone.on("success", function(file, message){
$("#msg").html(message);
//setTimeout(function(){window.location.href="index.php"},800);
});
myDropzone.on("error", function (data) {
$("#msg").html('<div class="alert alert-danger">There is some thing wrong, Please try again!</div>');
});
myDropzone.on("complete", function(file) {
myDropzone.removeFile(file);
});
$("#add_file").on("click",function (){
myDropzone.processQueue();
});
我希望我的用户上传以相同尺寸裁剪的所有图像。如果租约不可能有多个,请帮我一张图片。
笔记:我没有使用引导程序
【问题讨论】:
标签: javascript html dropzone.js cropperjs