php - CI : You did not select a file to upload. 错误

标签 php mysql codeigniter

好的,这是我的 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);
    }

这是我的观点:

<?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'

看起来我输入的名称是错误的,但它是正确的,如何解决这个问题?

最佳答案

在 Controller 中:

更改此

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

查看中:

表格应该是这样的:

<?php echo form_open_multipart('member/buktisaldo');?>

关于php - CI : You did not select a file to upload. 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38387876/

相关文章:

PHP代码没有被执行,但代码显示在浏览器源代码中

php - 在 WordPress 中从我的数据库检索数据时出现问题

java - netbeans 中的组合框

php - 如何添加tr :nth-child inside tag table?

php - Codeigniter 项目在本地工作但不在线 - 找不到 404 页面

php - Codeigniter,路由在生产服务器上不起作用

PHP 添加 html 标签白名单以清理输入

php - AmCharts 与 MySQL

mysql - SQL DML : Incorrect date value (MySQL)

Php - 使用 join() 时我可以忽略/跳过空字符串吗