Answer the question
In order to leave comments, you need to log in
How to properly use dropzone.js in yii2?
I have this field in view:
<div class="form-group row">
<label for="input1" class="col-sm-2 col-form-label">
<?= $model->getAttributeLabel('photo') ?>
</label>
<div class="col-sm-10 js__dropzone js__dropmulti">
<div class="dz-message needsclick">
Drop photo here or click to upload.
</div>
<?= $form
->field($model, 'photo')
->hiddenInput([
'class' => 'js__dropzone__hidden-file-name'
])
->label(false) ?>
</div>
</div>
$(".js__dropzone").dropzone({
parallelUploads: 1,
uploadMultiple: false,
acceptedFiles: "image/*",
maxFiles: 3,
url: "/ajax/drop-zone",
previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-image\"><img data-dz-thumbnail /></div>\n <div class=\"dz-details\">\n <div class=\"dz-size\"><span data-dz-size></span></div>\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n </div>\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n </div>",
init: function() {
this.on("maxfilesexceeded", function(file) {
this.removeAllFiles();
this.addFile(file);
});
},
success: function (file, response) {
if (response.result != undefined && response.result == 'success') {
$('.js__dropzone__hidden-file-name').val(response.fileName);
}
}
});
->hiddenInput()
. how can I replace it so that the names of both photos are sent to the server and that this element is not displayed on the page? using vanilla dropzone.js
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question