2

这是文件上传的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);
    }
}

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

4

1 回答 1

0

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

$config['file_name']

尝试重命名它,看看它是否有效。此外,您没有使用 $config['allowed_types'] 来指定可以上传哪些文件。否则有什么办法阻止某人上传讨厌的文件?

于 2013-02-27T12:46:43.150 回答