Exemplo n.º 1
0
 public function index()
 {
     $u = new SwfUpload();
     $t = new Thumbnail();
     $u->files = $_FILES;
     //设置file数组。(只能单张)
     //请记住先检测,再上传
     $r = $u->check();
     if ($r === true && ($r = $u->upload())) {
         //            echo_log($r);
         if (!isset($r['error'])) {
             // 生成200的缩略图
             $t->setSrcImg($r['savePath']);
             $height = $t->getImgHeight();
             $width = $t->getImgWidth();
             if ($this->savePicture($r['saveName'], $r['title'], $width, $height)) {
                 // 生成小的缩略图
                 $t->setDstImg($r['savePath'] . '_' . THUMBNAIL_WIDTH_SMALL);
                 $t->createImg(THUMBNAIL_WIDTH_SMALL);
                 // 生成打的缩略图
                 $t->setSrcImg($r['savePath']);
                 $t->setDstImg($r['savePath'] . '_' . THUMBNAIL_WIDTH_LARGE);
                 $t->createImg(THUMBNAIL_WIDTH_LARGE);
                 $rt = array('thumbUrl' => $r['saveName'], 'title' => $r['title'], 'width' => $width, 'height' => $height);
                 json_success($rt);
             } else {
                 json_failure('图片信息入库异常');
             }
         } else {
             json_failure($r['error']);
         }
     } else {
         json_failure($r['error']);
     }
 }
Exemplo n.º 2
0
 /**
  * 置顶展示设置
  */
 public function setTopShow()
 {
     $pid = intval(get_query('pid', 0));
     $top = intval(get_query('top'));
     if (is_int($pid) && $pid > 0 && ($top == 1 || $top == -1)) {
         $data = array('id' => $pid, 'top_show' => $top, 'updatetime' => time());
         $r = $this->pM->save($data);
         if ($r) {
             json_success($data);
         }
         json_failure($data);
     }
 }