コード例 #1
0
 /**
  * swfupload 多图上传
  */
 public function swfupload2()
 {
     if (IS_POST) {
         //上传处理类
         $config = array('rootPath' => './' . C("UPLOADPATH"), 'savePath' => '', 'maxSize' => 11048576, 'saveName' => array('uniqid', ''), 'exts' => array('jpg', 'gif', 'png', 'jpeg', "txt", 'zip'), 'autoSub' => false);
         $upload = new \Think\Upload($config);
         $info = $upload->upload();
         //开始上传
         if ($info) {
             //上传成功
             //写入附件数据库信息
             $first = array_shift($info);
             if (!empty($first['url'])) {
                 $url = $first['url'];
             } else {
                 $url = C("TMPL_PARSE_STRING.__UPLOAD__") . $first['savename'];
             }
             //裁剪图片
             import("Resizeimage", UTIl);
             $resize = new \Resizeimage();
             $resize->initAttribute($config['rootPath'], 600, 600, 1);
             $cutimg = $resize->resize($first['savename']);
             echo "1," . $url . "," . '1,' . $first['name'];
             exit;
         } else {
             //上传失败,返回错误
             exit("0," . $upload->getError());
         }
     } else {
         $this->display(':swfupload2');
     }
 }
コード例 #2
0
ファイル: function.php プロジェクト: noikiy/luokeke2
function sp_check_thumb($url)
{
    $file = explode("/", $url);
    $count = count($file);
    $fileName = $file[$count - 1];
    $fileCata = $file[$count - 2];
    $fileThumb = './data/upload/' . $fileCata . '/thumb/' . $fileName;
    if (!file_exists($fileThumb)) {
        import("Resizeimage", UTIl);
        $resize = new \Resizeimage();
        $path = './data/upload/' . $fileCata . '/';
        $resize->initAttribute($path, 640, 640, 2);
        $result = $resize->resize($fileName);
        if ($result) {
            return $fileThumb;
        } else {
            return $url;
        }
    } else {
        return $fileThumb;
    }
}