我不明白为什么它只更新1张图片并循环播放
以下是html表单代码
<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);
}
这是模型中的查询
function updated_property_image_records($new_file_name, $id) {
$update = $this->db->query("UPDATE property_image SET image_name='$new_file_name' where property_id= '$id' ");
}