Php 在codeigniter中显示表单编辑的数据和图像
我有一个编辑表单,用户可以编辑和删除我的汽车模型。 当用户点击编辑时,他们可以在编辑表单上看到汽车、车型、年份、价格,并进行新的更改和提交。我想上传的图像显示和编辑以及。我知道form_input()无法显示图像。我尝试了一切,但它不会显示在我的编辑形式。这是我的密码,谢谢Php 在codeigniter中显示表单编辑的数据和图像,php,codeigniter,Php,Codeigniter,我有一个编辑表单,用户可以编辑和删除我的汽车模型。 当用户点击编辑时,他们可以在编辑表单上看到汽车、车型、年份、价格,并进行新的更改和提交。我想上传的图像显示和编辑以及。我知道form_input()无法显示图像。我尝试了一切,但它不会显示在我的编辑形式。这是我的密码,谢谢 controller: public function input($id = 0) { $this->load->helper('form'); $this->load->helper('ht
controller:
public function input($id = 0) {
$this->load->helper('form');
$this->load->helper('html');
$this->load->model('model_users');
/*
if($this->input->post('submit')) {
$this->model_users->entry_insert();
}
$data = $this->books_model->general();
*/
if((int)$id > 0) {
$query = $this->model_users->get($id);
$data['fid']['value'] = $query['id'];
$data['fcar_make']['value'] = $query['car_make'];
$data['fcar_model']['value'] = $query['car_model'];
$data['fcar_year']['value'] = $query['car_year'];
$data['fcar_lease']['value'] = $query['car_lease'];
$data['fcar_payment']['value'] = $query['car_payment'];
$data['fimgpath']['value'] = $query['imgpath'];
}
if($this->session->userdata('is_logged_in')) {
$this->load->view('edit_car',$data);
}
else {
redirect('main/restricted');
}
}
Model:
function get($id) {
$this->db->where(array('id'=>$id));
$query = $this->db->get('cars');
return $query->row_array();
}
view
<tr>
<td>Car Lease:</td>
<td><input type="text" class="textbox" tabindex="6" name = "<?php echo form_input($fcar_lease); ?></td>
<td> </td>
</tr>
<tr>
<td>Car Payment:</td>
<td><input type="text" class="textbox" tabindex="6" name = "<?php echo form_input($fcar_payment); ?></td>
<td> </td>
</tr>
<tr>
<td>Car Image:</td>
<td><input type="file" name=""<?php echo form_input($fimgpath); ?>" size="20" /></td>
<td> </td>
</tr>
控制器:
公共函数输入($id=0){
$this->load->helper('form');
$this->load->helper('html');
$this->load->model('model_users');
/*
如果($this->input->post('submit')){
$this->model_users->entry_insert();
}
$data=$this->books_model->general();
*/
如果((int)$id>0){
$query=$this->model\u users->get($id);
$data['fid']['value']=$query['id'];
$data['fcar_make']['value']=$query['car_make'];
$data['fcar_model']['value']=$query['car_model'];
$data['fcar_year']['value']=$query['car_year'];
$data['fcar_lease']['value']=$query['car_lease'];
$data['fcar\u payment']['value']=$query['car\u payment'];
$data['fimgpath']['value']=$query['imgpath'];
}
如果($this->session->userdata('is\u logged\u in')){
$this->load->view('edit_car',$data);
}
否则{
重定向(“主/受限”);
}
}
型号:
函数get($id){
$this->db->where(数组('id'=>$id));
$query=$this->db->get('cars');
返回$query->row_array();
}
看法
汽车租赁:
您不能在文件上载字段中显示图像或图像路径,而只能在文件上载字段下显示图像(就像在前端显示一样),如果用户重新上载图像,请删除现有图像,上载新图像,并在数据库中更新图像名
此外,您还可以在同一界面上(可能在当前图像下方)提供一个删除按钮来删除图像。是否编辑?他们想上传新的图片,而不是现有的图片,或者进行图片编辑?顺便说一句,我把这个放在了我的代码中,但是所有的图片都出现在foreach($imagesas$row){?>imgpath,'/');?>“>用户可以上传多张图像吗?例如,如果他们单击编辑Acura,在编辑汽车页面上,Acura汽车附带汽车租赁、汽车年份和仅显示Acura图像,则应仅显示Acura图像。否,在图像上有一个删除按钮,或者如果用户重新上传图像,则替换现有图像。这很简单,不是吗?