As for the drop zone to display already uploaded images?

Hi all, anyone familiar with Dropzones tell me how it is possible to put the files when you Update the object, that is, that was preview container display images already on the server and in the database, the way to images passing through the model, but as it is their right thumbs stick? Notkola this pattern
// Create the mock file:
var mockFile = { name: "Filename", size: 12345 };

// Call the default addedfile event handler
myDropzone.emit("addedfile", mockFile);

// And optionally show the thumbnail of the file:
myDropzone.emit("thumbnail", mockFile, "/image/url");
// Or if the file on your server is not yet in the right
// size, you can let Dropzone download and resize it
// callback and by adding crossorigin are optional.
myDropzone.createThumbnailFromUrl(file, imageUrl, callback, by adding crossorigin);

// Make sure that there is no progress bar, etc...
myDropzone.emit("complete", mockFile);

// If you use the maxFiles option, make sure you adjust it to the
// correct amount:
var existingFileCount = 1; // The number of files already uploaded
myDropzone.options.maxFiles = myDropzone.options.maxFiles - existingFileCount;


poked, and realized that I do not understand... ,do not explain to JS cripple?)

The fact that he raises events and pushes them to the old is clear, but I have something not worked and do not understand, this is all you need to perform, or for different cases, methods? and anyway, I drop a zone via the plugin yii2 start, but there are the same kind, just by the events themselves a little understood.
June 10th 19 at 16:38
2 answers
June 10th 19 at 16:40
Solution
In Html

//Counter
<?php $counter = 0; ?>

<?php foreach ($model--->images as $image): ?>

<?php
++$counter;
?>

 <div class="server_img" id="server_img_<?= $counter ?>"><?= $image--->name ?></div>

<?php endforeach; ?>


After the form to register Js

//The number of blocks with the class .server_img(That is, blocks with names)
var path = $('.server_img').length;

//How many images, so many cycles
for (i = 1; i <= path; i++) {

 //The name of each
 var img_name = $('#server_img_' + i).text(),
 mockFile = { name: img_name };

//Add file drop-zon through the event
myDropzone.emit("addedfile", mockFile);

//Making pravuju Url where you store the uploaded images
myDropzone.emit("thumbnail", mockFile, "/web/upload/store/Products/" + mockFile.name);

//Give the status of the uploaded
myDropzone.emit("complete", mockFile);

 }
June 10th 19 at 16:42
To choose the right tool and do not suffer.
plugins.krajee.com/file-input/demo
Already familiar with this extension, it does not satisfy other requests, when you create a product, dz came, but now you just need to display existing pictures in the area, for this, even a function (above) I just did not understand it, so how much JS do not understand, it is not logical not understanding the methods suitable tool to change it to another, because with him more and more to understand. This asked who can already updates through a Drop-zone, but still thank you) - Gretchen_Daniel commented on June 10th 19 at 16:45
That DZ is such that there is at BU? - maci_Walk commented on June 10th 19 at 16:48
Maybe it is) But I couldn't find the correct solution, I need when creating forms dynamically add input['FormName']['images'][] with the path to the image that is created on the server, and if the form is submitted to save previewname and the ability to remove a picture or add the client and then send to the server (Synchronously), and then I separately upload the pictures, then click upload separately and then sent together with the form, in short a lot of unnecessary action and crap which is not understood, and so can you all realize, did not understand simple. - Gretchen_Daniel commented on June 10th 19 at 16:51
in BU, it's all there by default. And the creation of additional inputof and all sorts of handlers and events. See the examples in the section Example. - maci_Walk commented on June 10th 19 at 16:54
Understand) thank you, the time will deal with documentally, the solution by the way DZ did this to change the loader there is no need, but there is a time and BU will understand. Here is the answer can someone come in handy.

Php derive hidden ipnut or stupid divas with names pictures.

Then in Js in a loop adding each to the DZ, write JS code after the form

//The number of blocks with the class .server_img(That is, blocks with names)
var path = $('.server_img').length;

//How many images, so many cycles
for (i = 1; i <= path; i++) {

 //The name of each
 var img_name = $('#server_img_' + i).text(),
 mockFile = { name: img_name };

//Add file drop-zon through the event
myDropzone.emit("addedfile", mockFile);

//Making pravuju Url where you store the uploaded images
myDropzone.emit("thumbnail", mockFile, "/web/upload/store/Products/" + mockFile.name);

//Give the status of the uploaded
myDropzone.emit("complete", mockFile);

 }


Of course clumsy in haste, but it works) - Gretchen_Daniel commented on June 10th 19 at 16:57

Find more questions by tags JavaScript