doudao7511 2019-02-26 11:33
浏览 39

如何通过codeigniter编辑附加div的图像

i need help for update image with appended div. i put image for insert data with appended div it was done by me but i need some help for edit time.

i used this table for store data

CREATE TABLE `special_offers` (
  `id` int(11) NOT NULL,
  `listing_id` int(255) NOT NULL,
  `special_offer_image` varchar(200) NOT NULL,
  `special_offer_title` varchar(255) NOT NULL,
  `special_offer_description` varchar(255) NOT NULL,
  `special_offer_price` varchar(255) NOT NULL,
  `creation_date` datetime(6) NOT NULL,
  `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0=active, 1=inactive'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

enter image description here i put code for edit with carry array for data.

<div class="row">
                <div class="col-md-12">
                    <h6>Items</h6>
                    <table id="pricing-list-container" style="width:100%;">
                        <?php if(isset($listing_special_offer_data)){ ?>
                        <?php foreach($listing_special_offer_data as $key => $special_offer){?>
                        <tr class="pricing-list-item">
                            <td>
                                <div class="row">
                                    <div class="col-md-3">
                                        <center><img hight="100" width="100" src="<?php echo base_url('assets/upload/listing/prising_image/')?><?php echo $special_offer['special_offer_image'];?>"></center>
                                        <br>
                                        <div class="form-group">
                                            <input type="file" multiple="multiple" name="special_offers_image[]" class="form-control"  value="<?php echo $special_offer['special_offer_title'];?>">
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <input type="text" name="special_offers_title[]"class="form-control" placeholder="Special offer Title" value="<?php echo $special_offer['special_offer_title'];?>">
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <input type="text" name="special_offers_description[]" class="form-control" placeholder="Special offer Description" value="<?php echo $special_offer['special_offer_description'];?>">
                                        </div>
                                    </div>
                                    <div class="col-md-2">
                                        <div class="form-group">
                                            <input type="text" name="special_offers_price[]" class="form-control"  placeholder="Offer Price" value="<?php echo $special_offer['special_offer_price'];?>">
                                        </div>
                                    </div>
                                    <div class="col-md-1">
                                        <div class="form-group">
                                            <a class="del_button" href="<?php echo base_url('listing/delete_special_offer/')?><?php echo $special_offer['id'] ?>"><i class="fa fa-fw fa-remove"></i></a>
                                        </div>
                                    </div>
                                </div>
                                <hr>
                            </td>
                        </tr>
                        <?php }?>
                    <?php }else{?>
                        <tr class="pricing-list-item">
                            <td>
                                <div class="row">
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <input type="file" multiple="multiple" name="special_offers_image[]" class="form-control" />
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <input type="text" name="special_offers_title[]"class="form-control" placeholder="Special offer Title">
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <input type="text" name="special_offers_description[]" class="form-control" placeholder="Special offer Description">
                                        </div>
                                    </div>
                                    <div class="col-md-2">
                                        <div class="form-group">
                                            <input type="text" name="special_offers_price[]" class="form-control"  placeholder="Offer Price">
                                        </div>
                                    </div>
                                    <div class="col-md-1">
                                        <div class="form-group">
                                            <a class="delete" href="#"><i class="fa fa-fw fa-remove"></i></a>
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    <?php }?>
                    </table>
                    <a href="#0" class="btn_1 gray add-pricing-list-item"><i class="fa fa-fw fa-plus-circle"></i>Add offers</a>
                    </div>
            </div>

i put image for edit page show-data with appended div

enter image description here

when i click on add offers button then how can i upload image in appended div

so .. how can i do ?

  • i want to change second appended row image and first row same it is
    in edit.

  • i want to delete forth appended row and add another new

    div .

  • i want to can't update any image in appended rows .

I put code for upload image

$offer_ImageCount = count($_FILES['special_offers_image']['name']);
                    for($i = 0; $i < $offer_ImageCount; $i++){
                        $_FILES['file']['name']       = $_FILES['special_offers_image']['name'][$i];
                        $_FILES['file']['type']       = $_FILES['special_offers_image']['type'][$i];
                        $_FILES['file']['tmp_name']   = $_FILES['special_offers_image']['tmp_name'][$i];
                        $_FILES['file']['error']      = $_FILES['special_offers_image']['error'][$i];
                        $_FILES['file']['size']       = $_FILES['special_offers_image']['size'][$i];
                        $config['upload_path']        = './assets/upload/listing/prising_image';
                        $config['allowed_types']      = 'jpg|jpeg|png|gif';
                        $this->load->library('upload', $config);
                        $this->upload->initialize($config);
                        if($this->upload->do_upload('file')){
                        $offer_imageData = $this->upload->data();
                        $offer_uploadImgData[] = $offer_imageData['file_name'];
                        }
                    }
                    $special_offers_image = $offer_uploadImgData;

please help me. thanks in advance

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?