gpt4 book ai didi

php - 文件未在 codeigniter 中上传

转载 作者:行者123 更新时间:2023-11-28 03:34:51 25 4
gpt4 key购买 nike

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

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

最佳答案

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

$config['file_name']

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

关于php - 文件未在 codeigniter 中上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15106522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com