错误是:您没有选择要上传的文件。
我的控制器:
$image_name=$_FILES['screen_img']['name'];
$config['upload_path']=FCPATH.'asset/project_images/';
$config['allowed_types']='jpeg|jpg|png';
$config['overwrite']=true;
$config['max_size']="2048000";
$config['file_name']=$image_name;
$config['max_height']="768";
$config['max_width']="1024";
$this->load->library('upload');
$this->upload->initialize($config);
if(!$this->upload->do_upload($image_name))
{
$error = array('error' => $this->upload->display_errors());
print_r($error);
$this->load->view('screen/new_screen', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
print_r($data);
$this->load->view('screen/new_screen',$data);
}
我的观点
<?php echo form_open_multipart('screen/new_screen')?>
<input type="file" class="form-control" name="screen_img" /><br>
<input type="submit" class="btn btn-success" name="submit" value="submit">
<?php echo form_close();?>
我尝试了所有互联网的例子,但它们没有用。我找不到问题。
答案 0 :(得分:1)
您需要在do_upload函数中编写字段名称
SELECT
id
FROM relationships a
WHERE
a.term_id = 5 AND
EXISTS (SELECT * FROM relationships b WHERE b.term_id = 8 AND b.id = a.id) > 0
而不是if(!$this->upload->do_upload("screen_img"))