예제 #1
0
 public function add()
 {
     $model = M('simg');
     $upload = new \Org\Net\UploadFile();
     $upload->maxSize = 3145728;
     $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
     $upload->savePath = './Public/images/';
     $upload->saveRule = time();
     $result = $upload->upload();
     if ($result) {
         $info = $upload->getUploadFileInfo();
         $data['img'] = $info[0]['savename'];
         dump($data['img']);
     }
     $data['sid'] = $_GET['id'];
     if ($result) {
         $ok = $model->add($data);
         if ($ok) {
             $this->success('ok');
         }
     }
     $arr = $model->where('sid=%d', $_GET['id'])->select();
     dump($arr);
     $this->assign('arr', $arr);
     $this->display();
 }
예제 #2
0
 protected function upload_file()
 {
     $upload = new \Org\Net\UploadFile();
     $upload->maxSize = 3145728;
     $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
     $upload->savePath = './Public/images/';
     $upload->saveRule = time();
     $result = $upload->upload();
     /*if($result === false){
     			$data['info'] = "上传失败!!";
     			$data['status'] = self::ERR + __LINE__;
     			$this->ajaxReturn($data);
     		}*/
     $info = $upload->getUploadFileInfo();
     $data = $info[0]['savename'];
     return $data;
 }
예제 #3
0
 function _Upload()
 {
     $upload = new \Org\Net\UploadFile();
     $upload->thumb = true;
     $upload->saveRule = $this->saveRule;
     //图片命名规则
     $upload->thumbMaxWidth = $this->thumbMaxWidth;
     $upload->thumbMaxHeight = $this->thumbMaxHeight;
     $upload->maxSize = C('ADMIN_MAX_UPLOAD');
     // 设置附件上传大小
     $upload->allowExts = C('ADMIN_ALLOW_EXTS');
     // 设置附件上传类型
     $upload->savePath = $this->savePathNew ? $this->savePathNew : C('ADMIN_UPLOAD_DIR');
     // 设置附件上传目录
     if (!$upload->upload()) {
         // 上传错误提示错误信息
         $this->error($upload->getErrorMsg());
     } else {
         // 上传成功 获取上传文件信息
         $info = $upload->getUploadFileInfo();
     }
     return $info;
 }