Php 上载图像,但协调器中出现一些错误
我想尝试图像上传,但图像未上传,出现一些错误。我正在使用PHP框架 请帮帮我 协调员在此处插入代码Php 上载图像,但协调器中出现一些错误,php,Php,我想尝试图像上传,但图像未上传,出现一些错误。我正在使用PHP框架 请帮帮我 协调员在此处插入代码 public function req() { $userID = $this->input->post('userID'); $fname = $this->input->post('fname'); $dept_req = $this->input->post('dept_req'
public function req()
{
$userID = $this->input->post('userID');
$fname = $this->input->post('fname');
$dept_req = $this->input->post('dept_req');
$except_id = $this->input->post('except_id');
$message = $this->input->post('message');
$posted = $this->input->post('posted');
$_FILES['photo']['name'];
$config['upload_path'] = 'uploads/';
$config['allowed_types'] = 'jpg|jpeg|png|gif';
$config['file_name'] = $_FILES['photo']['name'];
$this->load->library('upload',$config);
$this->upload->initialize($config);
$data = [
'userID' => $userID,
'fname'=> $fname,
'dept_req'=> $dept_req,
'except_id'=> $except_id,
'message' => $message,
'photo' => $picture,
'posted' => $posted
];
您好,请在此处添加您正在获取的错误消息图像链接错误请检查图像Sir当图片实际上是文本时不要发布图片。错误消息很重要。请将错误文本(不是图片,无法搜索或复制)粘贴到上述问题中。谢谢。不管怎样,这个错误很明显。您没有为数据库中的“photo”列提供值,这是必需的(因为不允许空值)。如果我们看一下您的代码,我们会发现这是因为您编写了
'photo'=>$picture
,但在PHP代码中,您从未创建或填充名为$picture的变量。这是一个空变量。在创建查询之前,需要向该变量添加一些数据。