Answer the question
In order to leave comments, you need to log in
How to get nested images on form submission?
There is a task editing form. A task can have nested images. The images are stored on the server, and the path to the mini-image and its original is stored in the database.
HTML:
<div class="form-group col-md-12" style="padding-left: 0px;">
<label>Изображения<i class="fa fa-info-circle text-muted pull-right inform" data-toggle="tooltip" data-placement="top" title="" data-original-title="Поле не обязательно к заполнению"></i></label>
<?php if (is_array($images_task)): ?>
<div class="container1">
<div id="gallery1">
<?php foreach ($images_task as $img): ?>
<div class="form-photo">
<div class="photo1">
<a href="/upload/images<?=$img['full']?>" data-lightbox="roadtrip"><img src="/upload/images<?=$img['mini']?>" alt="<?=$task['name']?>" /></a>
</div>
<button class="del" style="float: left;" type="button"><i class="mdi mdi-close-box" style="float: left;"></i></button>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
</div>
Answer the question
In order to leave comments, you need to log in
Your form must somehow tell the server that the user has deleted the files.
For example, in hidden input fields (with type="hidden") keep a list of metadata (id or file name) of remote files that were uploaded to the server earlier. When submitting the form, compare the list of deleted files and existing files.
If the form is not sent in its entirety in the usual sense, then using Ajax requests, when you click on delete, tell the server what exactly was deleted.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question