我想調整在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