繁体   English   中英

文件未在Codeigniter中上传

[英]File not uploading in codeigniter

这是用于文件上传的codeigniter函数

public function doctor_signup()
{ 
    $this->load->library('encrypt');
    $rand = time() . rand(0, 9999);

    if($_FILES["file"]["name"]!="") 
    {
        $config['upload_path'] = realpath(dirname(__FILE__)). '/uploads/';
        $config['max_size'] = '100';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        $config['name']=$rand;
        print_r($config);


        $this->load->library('upload', $config);

        if ( ! $this->upload->do_upload()) 
        {
            echo $error = array('error' => $this->upload->display_errors());
            exit;
        }
    }   


    $data = array(
        'username' => $_POST['username'],
        'password' => $this->encrypt->encode($_POST['password']),
        'name' => $_POST['name'],
        'address' => $_POST['address'],     
        'city' => $_POST['city'],       
        'state' => $_POST['state'],                                                 
        'photo'=> $rand,
        'email' => $_POST['email'],
        'date_of_join'=>date('Y-m-d H:m:s'),
        'landline' => $_POST['landline'],
        'mobile' => $_POST['mobile'],
        'specialist' => $_POST['specialist'],
        'comments' => $_POST['comments'],
        'degree' => $_POST['degree']
    );


    if( $this->db->insert('doctor_user', $data)) 
    {
        $this->load->view('header', $data);
        $this->load->view('user_created', $data);
        $this->load->view('footer', $data);
    }
}

但是文件没有上传到上传目录,也没有出现任何错误。 主目录下的uploads文件夹。 任何建议。 谢谢

我认为可能是因为$ config ['name']应该是

$config['file_name']

尝试重命名它,看看是否可行。 另外,您没有使用$ config ['allowed_types']指定可以上传哪些文件。 否则,如何阻止某人上传讨厌的文件?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM