我想调整在codeigniter中上传的图像,但它不适用于此代码。图像上传成功,但我想调整到110x110并显示它!我想调整在codeigniter中上传的图像,但它不起作用
我的代码是在这里
class Upload_photo extends CI_Controller{
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
}
public function index(){
session_start();
$u = $_SESSION['username'];
$config['upload_path'] = 'user/'.$u.'/'.$filename;
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '30000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload',$config);
if(!$this->upload->do_upload('file1'))
{
echo "Error". $this->upload->display_errors();
}
else {
$config['image_library'] = 'GD2';
$config['source_image'] = $config['upload_path'];
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 110;
$config['height'] = 110;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
echo 'Photo Uploaded Successfully';
}
}
}
我得到“到图像的路径是不正确的”错误! – jems
是的,这意味着您需要检查路径是否首先存在。 – Linesofcode