|
楼主 |
发表于 2011-1-3 13:30:53
|
显示全部楼层
本帖最后由 see52001 于 2011-1-3 15:24 编辑
以下是我的程式碼
當然 這邊 有把沒關聯的程式拿掉
只是把重點 寫出來而已
用到的檔案
controllers
test.php
model
admin_model.php
test_model.php
libraries
Upload.php
MY_Table_Set.php
程式碼
test.php
class test extends Controller {
public function __construct(){
parent::controller();
$this->load->model("test_model","model");
}
public index(){
if( 條件成立 ){
$this->model->_updata();
}
}
}
admin_model.php
class Admin_Model extends Model{
function __construct()
{
parent::Model();
$this->load->database();
}
}
test_model.php
class Test_Model extends Admin_Model{
public function __construct(){
parent::__constructl();
$this->load->library("MY_Table_Set");
}
public function _updata()
{
$value = $this->my_table_set->_upload_file($col_name,$upload_dir,$self_page,$hidden_name , $file = 'file'); //就是這邊開始有問題 , 參數我就不帶了
....
....
parent::_updata( $value , $where , $this->_list_tb );
}
}
MY_Table_Set.php
class MY_Table_Set extends Model{
public function __construct(){
parent::Model();
}
//設定檔案上傳
public function _upload_file($col_name,$upload_dir,$self_page,$hidden_name , $file = 'file')
{
if( $filename == '') return $hidden_name;
$config['upload_path'] = UPLOAD_DIR_PATH.$upload_dir;
$config['max_size'] = '2000';
if( $file == 'pic'){
$config['allowed_types'] = 'gif|jpg|png|bmp';
/*
$config['max_width'] = '50';
$config['max_height'] = '50';
*/
} else {
$config['allowed_types'] = $ext;
}
$this->load->library('upload', $config); // 這是這裡有問題,取得是null
//***
$CI =& get_instance();
$CI->load->library('upload');
也是不行
**//
//如果錯誤 顯示錯誤訊息
if ( !$this->upload->do_upload($col_name)) {
$error = $this->upload->display_errors('','\n');
show_message( $error, $return_page );
} else {
return $new_name;
}
}
} |
|