douyiyang6317
douyiyang6317
2016-07-15 04:28

CI:您没有选择要上传的文件。 错误

已采纳

okay, this is my controller :

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);
    }

and this is my view :

<?php echo form_open('member/buktisaldo');?>
<input type="file" name="bukti">
<input type="submit" value="send">
<?php echo form_close();?>

and when i run this code, it shows error "You did not select a file to upload."

this is var_dump() script :

UPDATE `saldo` SET `bukti` = '' WHERE `id_user` = '74' AND `status` = 'Sedang Diproses'

it seems like my input name is wrong, but its correct, how to fix that ?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • doumiang0597 doumiang0597 5年前

    In Controller :

    Change This

       $file_name = $this->upload->data('file_name'); 
       $data = array('bukti' => $file_name);
    

    In View :

    form should be like this :

    <?php echo form_open_multipart('member/buktisaldo');?>
    
    点赞 评论 复制链接分享

相关推荐