class Upload extends CI_Controller {
public function index()
{
$this->load->view(‘up’);
}
function up(){
if(!empty($_POST[‘sub’])){
$file=$_FILES[‘upfile’];
if($file[‘size’]>=200000){
echo ‘size no’;
}
else{
switch ($file[‘type’]){
case ‘image/png’:
$hou=’.png’;
break;
default:
$hou=false;
break;
}
if($hou){
$time=time();
move_uploaded_file($file[‘tmp_name’], “./upload/$time$hou”);
}
else{
echo ‘type no’;
}
}
}
}
function up1(){
$config[‘upload_path’]=’./upload’;
$config[‘allowed_types’]=’gif|jpg|png’;
$config[‘max_size’]=’2000′;
$this->load->library(‘upload’,$config);
if($this->upload->do_upload(‘upfile’)){
$data=array(‘upload_data’=>$this->upload->data());
var_dump($data);
}
else{
$error=array(‘error’=>$this->upload->display_errors());
var_dump($error);
}
}
}