我使用codeigniter上传库将图片上传到服务器。 它适用于所有其他图像类型,但我无法将png图像上传到在线服务器。此外,它在我的本地服务器上适用于所有图像类型,包括png。问题仅存在于png图像的服务器中
下面是我的控制器功能
function insertpartner(){
$data['success'] = "";
$data['error'] = "";
$this->load->library('form_validation', 'session');
$this->form_validation->set_error_delimiters('<div class="errorMsg">', '</div>');
$this->form_validation->set_rules('txtTitle', ' title', 'required');
if ($this->form_validation->run() == FALSE) {
redirect('sitemanager/partners/addpartners');
} else {
if (isset($_FILES['userfile']['tmp_name']) && $_FILES['userfile']['tmp_name'] != "") {
$config['upload_path'] = './uploads/partnerlogo/';
$config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';
//$config['max_size'] = '20000';
//$config['max_width'] = '800';
//$config['max_height'] = '700';
$this->load->library('upload', $config); //--------------- Loading image uploading library------------------
$configThumb = array();
$configThumb['image_library'] = 'gd2';
$configThumb['source_image'] = '';
$configThumb['maintain_ratio'] = TRUE;
$configThumb['width'] = 140;
$configThumb['height'] = 70;
$this->load->library('image_lib'); //--------------- Loading image_library for resizing the image-----
if (!$this->upload->do_upload('userfile')) {
$data['error'] = "<div class='error'>" . $this->upload->display_errors() . "</div>";
$data['success'] = "";
$data['category'] = $this->m_adminlogin->showcategories();
redirect('sitemanager/partners/addpartners',$data);
} else {
$data = $this->upload->data();
$imgPath = $data['file_name'];
$config['remove_space'] = TRUE;
$configThumb['source_image'] = $data['full_path'];
$configThumb['new_image'] = "./uploads/partnerlogo/thumbs/" . $data['file_name'];
$this->image_lib->initialize($configThumb);
if (!$this->image_lib->resize()) {
$data['error'] = "<div class='error'>Thumbnail creation failed.</div>";
$data['success'] = "";
redirect('sitemanager/partners/addpartners',$data);
}
}
}
//$url=$this->input->post('txturl');
//$url="http://".$url;
$partnerdetails = array(
'categoryId' => $this->input->post('selCategory'),
/* 'intfeatured' => $featured,*/
'name' => $this->input->post('txtTitle'),
'logo' => $imgPath,
'url' =>$this->input->post('txturl')
);
if ($this->m_partners->insertpartners($partnerdetails))
$this->session->set_flashdata('success', "<div class='success'>Successfully added Details.</div>");
else
$this->session->set_flashdata('failure', "<div class='error'>Try after sometimes.</div>");
redirect("sitemanager/partners/viewpartners", $data);
}
}