我想取消链接多张图片,而不是插入多张图片,这是我插入多张图片的代码,请帮忙
<form enctype="multipart/form-data" action="<?php echo base_url('admin/edit_property/' . $property['property_id']); ?>" class="form-horizontal" method="post" >
<div class="form-group">
<label class="col-md-3 control-label">Select Images</label>
<div class="col-md-8" style="margin-top:1%;">
<input type="file" name="files[]" id="file" multiple="multiple" >
<?php
foreach ($property_image as $property_images) {
?>
<img src="<?php echo base_url() . 'uploads/' . $property_images['image_name']; ?>" width="42" height="42">
<?php
}
?>
</div>
控制器“管理员”
foreach($_FILES["files"]["tmp_name"] as $key => $tmp_name) {
$temps = $_FILES["files"]["tmp_name"][$key];
$new_file_name = $_FILES["files"]["name"][$key];
move_uploaded_file($temps, "uploads/" . $new_file_name);
$this->crud_model->updated_property_image_records($new_file_name, $id);
这是我的模型“ Crud模型”
function updated_property_image_records($new_file_name, $id) {
$query = "insert into
property_image(image_name,property_id)values('$file_name','$id')";
$this->db->query($query);
}
function delete_property_image_records($id) {
$this->db->query("delete from property_image where property_id='" . $id . "'");
}
function get_image_records_by_id($id) {
$query = $this->db->query("SELECT * from property_image where property_id='" . $id . "' ");
return $query->result_array();
}