public function uploadImage($userfile = 'userfile'){
//公共部分不作爲參數,可變部分作爲參數
/*
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '2000';
$config['max_width'] = '1024';
$config['max_height'] = '768';*/
$config = $this->config->item('upload_p_w_picpath');
$config['file_name'] = date("YmdHis").rand(100,999);
$this->load->library('upload', $config);
$this->upload->initialize($config);
//參數:$_FILES數組的標籤
if($this->upload->do_upload($userfile)){
$fileInfo = $this->upload->data();
$_POST['p_w_picpath'] = $config['upload_path'].$fileInfo['file_name'];
$this->thumbImage($config['upload_path'].$fileInfo['file_name']);
}
}
public function thumbImage($source_p_w_picpath,$new_p_w_picpath=null){
$config = $this->config->item('thumb_p_w_picpath');//參數爲config數組標籤名
$config['source_p_w_picpath'] = $source_p_w_picpath;
$config['new_p_w_picpath'] = $config['thumb_path'].$new_p_w_picpath;
$this->load->library('p_w_picpath_lib', $config);
$this->p_w_picpath_lib->initialize($config);//以防萬一,文檔例子不可行時,加上此句
$this->p_w_picpath_lib->resize();
}