|
public function add_cate(){
$config['upload_path'] = './uploads/file/';
$config['allowed_types'] = 'xls|jpg|png|jpeg|txt|doc|css|zip';
$config['max_size'] = '10000';
$config['max_width'] = '1024';
$config['max_height'] = '1024';
$config['file_name'] = time() . mt_rand(1000,9999);//随机的名字
//载入上传类
$this->load->library('upload',$config);
//执行上传
if(!$this->upload->do_upload('file')){
echo "123";
$wrong = $this->upload->display_errors();
if($wrong){
echo "$wrong";
}
}else{
$info = $this->upload->data();
echo "<pre>";
print_r($info);
echo "</pre>";die;
$cid=$this->uri->segment(3);
$data=array(
'name'=>$_POST['name'],
'time'=>$_POST['time'],
'cid'=>$_POST['cid']
);
$this->load->model('file_model');
$this->file_model->add($data);
$url=site_url().'/file/file_list/'.'$cid';
echo "<script language=javascript>alert('上传成功!');location.href ='$url'</script>";
}
}
选择文件后点击提交 页面变成空白 什么都没有 经过测试 是$this->upload->do_upload('file')没有执行 希望大家帮忙看看 万分感谢!!!!!!!!!!!!! |
|