【问题标题】:File not uploading in codeigniter文件未在 codeigniter 中上传
【发布时间】:2013-02-12 22:21:10
【问题描述】:

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

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

【问题讨论】:

  • 你有足够的权限吗?
  • 检查您的上传文件夹权限
  • 我有所有权限
  • 可能想print_r($error) 得到它的输出,因为它是一个数组。
  • 另外,您是否在 codeigniter 中启用了错误日志记录?在config/config.php中设置$config['log_threshold'],并确保/application/logs文件夹有写权限。它可能会给你一些有用的东西。

标签: php html css codeigniter


【解决方案1】:

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

$config['file_name']

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

【讨论】:

    猜你喜欢
    • 2012-08-11
    • 1970-01-01
    • 2013-08-24
    • 1970-01-01
    • 1970-01-01
    • 2017-11-27
    • 1970-01-01
    • 2014-03-10
    • 2016-03-11
    相关资源
    最近更新 更多