1
我的代码如下,我无法将图像存储在codeigniter中的特定文件夹中。图像存储数据库表,但不存储在特定路径中。图像没有存储在使用codeigniter的文件夹中
控制器:
if (isset($_FILES['header_image']) && $_FILES['header_image']['name'] != "") {
$fileName="header_image_$id";
$ext= end(explode('.',$_FILES['header_image']['name']));
$file_name=$fileName.".".$ext;
$this->_upload('uploads/header_images/', "gif|jpg|png|jpeg", "header_image",$file_name);
$this->generic_model->updateRecord("blood_tips",array("header_image"=>'uploads/header_images/'.$fileName.".$ext"), array("id"=>$id));
}
private function _upload($uploadPath,$allowedTypes,$name,$file_name)
{
$config['file_name'] = $file_name;
$config['upload_path'] = $uploadPath;
$config['allowed_types'] = $allowedTypes;
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if (!$this->upload->do_upload($name))
{
return $this->upload->display_errors();
}
else
{
$data = array('upload_data' => $this->upload->data());
}
}
我也做,但没有,, :) – user3436031
代码在这里,你上传的,与修改建议应该正常工作。 如果您可以上传,完成控制器类和完全的表单代码,则可以提供帮助。 – Mobeen
它是否甚至显示由于最后一个条件而导致的错误?或者它也通过,如果条件? – Mobeen