当我尝试将图像上传到我的上传文件夹时,出现以下错误:
数组([错误] => 您没有选择要上传的文件。)
我的看法:
<form action="<?=base_url('create_public_profile_job') ?>" class="create-profile-form" method="POST">
<input type="file" name="userfile" size="20000" />
<button type="submit" class="create-profile-button">Submit</button>
</form>
我的控制器
public function create_public_profile_job()
{
if(isset($_POST['userfile']))
{
$this->User_model->do_upload($_POST['userfile']);
}
}
我的模型
public function do_upload($userfile)
{
$this->load->helper('form');
$this->load->helper('url');
$config['upload_path'] = 'assets/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1000000;
$config['max_width'] = 10240000;
$config['max_height'] = 7680000;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload($userfile))
{
$error = array('error' => $this->upload->display_errors());
print_r($userfile);
print_r($error);
}
else
{
$data = array('upload_data' => $this->upload->data());
print_r($data);
}
}
模型部分来自 Codeigniter 用户指南https://codeigniter.com/userguide3/libraries/file_uploading.html
真的不知道问题出在哪里,因为我通过所有功能传递图像
慕沐林林
江户川乱折腾
慕标5832272