删除选择的图像

There is a web-site with an orders, where each order has attaches(pictures) which we could see, but not remove.(Because using PrettyPhoto) Also using Fat Free Framework.


What i did yet:

Made output window with oportunity of choosen pictures with checkboxes and button delete and attached JQuery when click on delete btn. It's works fine while i don't agree the confirmation. Then nothing happens, and that's so bad for me. I hope tomorrow it will be working.
Primary web-page(part)
<div id="fileDelete" class="modal modal-userinfo hide fade">
<?php
    $Attaches = GetOrderAttaches($orderDetail->getID(), ATTACH_OWNER_ACCESSOR);
?>
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h3>Выберите файлы для удаления из заявки</h3>
</div>
<div class="modal-body">
    <form class="form-vertical">
        <fieldset>
            <div class="control-group">
                <label class="control-label" for="checkboxes">Прикреплённые файлы:</label>
                <div class="controls">
                    <ul class="thumbnails">
                        <?php foreach ($Attaches as $Attach) :?>
                            <li class="span1">
                                <label class="checkbox" for="checkboxes-<?php echo $Attach['AttachID']; ?>">
                                    <?php echo $Attach['FileName']; ?>
                                    <input type="checkbox" name="fileToDelete" id="checkboxes-<?php echo $Attach['AttachID']?>"
                                           value="<?php echo $Attach['AttachID']; ?>">

                                    <a href="<?php echo('/upload/files/' . $Attach['FileName']); ?>"
                                       class="thumbnail">
                                        <?php
                                            $thumbnail_src = (mb_strtolower(pathinfo($Attach['FileName'], PATHINFO_EXTENSION)) == 'pdf') ? 'pdf.jpg' : $Attach['FileName'];
                                        ?>
                                        <img src="<?php echo('/upload/files/thumbnail/' . $thumbnail_src); ?>"
                                             alt="<?php //echo $Attach['RealFileName'] ?> ">
                                    </a>
                                </label>
                            </li>
                        <?php endforeach ?>
                    </ul>
                </div>
            </div>
        </fieldset>
    </form>
</div>
<div class="modal-footer">
    <span class="btn btn-danger enabled">
        <span>Удалить</span>
        <input id="filedeletebtn" name="deletingfiles" type="button" multiple>
    </span>
</div>

Script responsible for deleting files on btnclick

    $('#filedeletebtn').on('click', function(){
    var iSelectedFiles = $('#fileDelete').find("input:checkbox:checked").serializeArray();
    var count = iSelectedFiles.length;
    if (count != 0) {
        var html = 'Вы действительно хотите удалить выбранные фото? Элементов: ' + count;
        bootbox.confirm(html, function (result) {
            if (result) {
                $.each(iSelectedFiles, function (index, file) {
                    $.ajax({
                        type: 'POST',
                        url: 'api/order/images/' + file.value,
                        data: file.value
                    })
                        .fail(function (file, textStatus, jqXHR) {
                            bootbox.alert('Возникла проблема при удалении изображений: </br>' + file.statusText);
                        });
                });
            }
        });
    } else {
        bootbox.alert('Выберите файлы для удаления!');
    }
});

In file api/index.php added

F3::route('POST /order/images/@ID [ajax]', 'OrderController->deleteImages');

In controller Order.php added

public function deleteImages()
{
    try {
        $data = $_POST['data'];
        $queryFileName = Dbh::getInstance()->prepare("DELETE FROM attaches WHERE attachID=?");
        $queryFileName->execute(array($data));
    } catch (Exception $e){
        $this->output['error'] = true;
        $this->output['message'] = $e->getMessage();
    }
}


So, how to make it alive?? Can't understand what's wrong.

So... I did it! In controller file was needed to change row on:

$data = $_POST['value'];

In the script file where AJAX was needed to change row on:

$.ajax({
      type: 'POST',
      url: 'api/order/images/' + file.value,
      data: file
})

Looks like it was small thing, but yesterday i spend all day for solving this problem) Hope, that my experience will help anybody.