Example #1
0
 /**
  * 上传图片
  * @author huajie <*****@*****.**>
  */
 public function uploadPicture()
 {
     //TODO: 用户登录检测
     /* 返回标准数据 */
     $return = array('status' => 1, 'info' => '上传成功', 'data' => '');
     /* 调用文件上传组件上传文件 */
     $Picture = new PictureModel();
     $pic_driver = C('PICTURE_UPLOAD_DRIVER');
     $info = $Picture->upload($_FILES, C('PICTURE_UPLOAD'), C('PICTURE_UPLOAD_DRIVER'), C("UPLOAD_{$pic_driver}_CONFIG"));
     //TODO:上传到远程服务器
     /* 记录图片信息 */
     if ($info) {
         $dd = getimagesize($_FILES["download"]["tmp_name"]);
         $return['status'] = 1;
         $return["width"] = $dd[0];
         $return["height"] = $dd[1];
         $return = array_merge($info['download'], $return);
     } else {
         $return['status'] = 0;
         $return['info'] = $Picture->getError();
     }
 public function uploadPicture()
 {
     if (IS_POST) {
         /* 返回标准数据 */
         $return = array('status' => 1, 'info' => '上传成功', 'data' => '');
         /* 调用文件上传组件上传文件 */
         $Picture = new PictureModel();
         $pic_driver = C('PICTURE_UPLOAD_DRIVER');
         $info = $Picture->upload($_FILES, C('PICTURE_UPLOAD'), C('PICTURE_UPLOAD_DRIVER'), C("UPLOAD_{$pic_driver}_CONFIG"));
         //TODO:上传到远程服务器
         /* 记录图片信息 */
         if ($info) {
             $return['status'] = 1;
             $return = array_merge($info['download'], $return);
         } else {
             $return['status'] = 0;
             $return['info'] = $Picture->getError();
         }
         //			dump($return);
         /* 返回JSON数据 */
         $this->ajaxReturn($return);
     }
 }