public function buktisaldo(){
//load library
$this->load->library('upload');
//Set the config
$config['upload_path'] = "./assets/images/campaigner/";
$config['allowed_types'] = "*";
//Initialize
$this->upload->initialize($config);
//Upload file
if( !$this->upload->do_upload("bukti")){
//echo the errors
echo $this->upload->display_errors();
}
$data = array(
'bukti' => $this->upload->file_name
);
$id = $this->session->userdata('id');
$this->db->where('id_user',$id);
$this->db->where('status','Sedang Diproses');
$this->db->update('saldo',$data);
$this->load->view('v_atas',$data);
$this->load->view('e_konfirmasisaldo',$data);
$this->load->view('v_bawah',$data);
}
这是我的观点:
<?php echo form_open('member/buktisaldo');?>
<input type="file" name="bukti">
<input type="submit" value="send">
<?php echo form_close();?>
当我运行此代码时,它显示错误“您没有选择要上传的文件。”
这是var_dump()
脚本:
UPDATE `saldo` SET `bukti` = '' WHERE `id_user` = '74' AND `status` = 'Sedang Diproses'
似乎我的输入名称是错误的,但是正确的,如何修复它?
答案 0 :(得分:1)
在控制器中:
更改此
$file_name = $this->upload->data('file_name');
$data = array('bukti' => $file_name);
在视图中
表格应该是这样的:
<?php echo form_open_multipart('member/buktisaldo');?>