1
我有CI類圖像的問題,圖像不調整...codeiginter上傳和調整
例如:
控制器
private function _do_upload(){
$config['upload_path'] = 'upload/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1000; //set max size allowed in Kilobyte
$config['max_width'] = 1000; // set max width image allowed
$config['max_height'] = 1000; // set max height allowed
$config['file_name'] = round(microtime(true) * 1000);
$this->load->library('upload', $config);
if($this->upload->do_upload('photo')) //upload and validate{
$config2['image_library'] = 'gd2';
$config2['source_image'] = $this->upload->upload_path;
$config2['create_thumb'] = TRUE;
$config2['maintain_ratio'] = TRUE;
$config2['width'] = 450;
$config2['height'] = 500;
$this->load->library('image_lib', $config2);
if(!$this->image_lib->resize()){
$data['inputerror'][] = 'photo';
$data['error_string'][] = 'Upload error: '.$this->upload->display_errors('','');
$data['status'] = FALSE;
}
return $this->upload->data('file_name');
}else{
$data['inputerror'][] = 'photo';
$data['error_string'][] = 'Upload error: '.$this->upload->display_errors('',''); //show ajax error
$data['status'] = FALSE;
echo json_encode($data);
exit();
}
}
但我沒有錯誤,我不知道錯誤在哪裏?
謝謝您的回答,我必須解決但仍然可以上傳圖片但無法調整大小,我不知道別人的錯誤在哪裏? – Anonymous
謝謝TimBrownlaw我的網站已成功運行 – Anonymous
歡迎您:)祝您好運。 – TimBrownlaw