Browse Source

上传文件至 ''

牛头人酋长 6 years ago
parent
commit
3fec670b46
5 changed files with 219 additions and 0 deletions
  1. 56 0
      File.php
  2. 52 0
      HomeBase.php
  3. 33 0
      Index.php
  4. 34 0
      common.php
  5. 44 0
      config.php

+ 56 - 0
File.php

@@ -0,0 +1,56 @@
+<?php
+// +---------------------------------------------------------------------+
+// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
+// +---------------------------------------------------------------------+
+// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
+// +---------------------------------------------------------------------+
+// | Author     | Bigotry <3162875@qq.com>                               |
+// +---------------------------------------------------------------------+
+// | Repository | https://gitee.com/Bigotry/OneBase                      |
+// +---------------------------------------------------------------------+
+
+namespace app\home\controller;
+use app\common\logic\File as LogicFile;
+use app\home\logic\HomeBase;
+
+/**
+ * 文件控制器
+ */
+class File extends HomeBase
+{
+    
+    /**
+     * 图片上传
+     */
+    public function pictureUpload()
+    {
+        
+        $result = $this->logicFile->pictureUpload();
+
+        return json($result);
+    }
+    
+    /**
+     * 文件上传
+     */
+    public function fileUpload()
+    {
+        
+        $result = $this->logicFile->fileUpload();
+
+        return json($result);
+    }
+    
+    /**
+     * 编辑器图片上传
+     */
+    public function editorPictureUpload()
+    {
+        
+        $result = get_sington_object('fileLogic', LogicFile::class)->pictureUpload('imgFile');
+        
+        $data  = false === $result ? [RESULT_ERROR => DATA_NORMAL, RESULT_MESSAGE => '文件上传失败'] : [RESULT_ERROR => DATA_DISABLE, RESULT_URL => get_picture_url($result['id'])];
+        
+        return throw_response_exception($data);
+    }
+}

+ 52 - 0
HomeBase.php

@@ -0,0 +1,52 @@
+<?php
+namespace app\home\controller;
+
+use app\common\controller\ControllerBase;
+
+/**
+ * 前台基类控制器
+ */
+class HomeBase extends ControllerBase
+{
+
+    // 页面标题
+    protected $title            =   '';
+
+    /**
+     * 构造方法
+     */
+    public function __construct()
+    {
+
+        // 执行父类构造方法
+        parent::__construct();
+
+        // 初始化前台信息
+        $this->initBaseInfo();
+
+    }
+
+
+    /**
+     * 初始化基础数据
+     */
+    final private function initBaseInfo()
+    {
+        //判断用户是否登录
+        if(session('user_info.id') < 1)
+        {
+            $this->jump(RESULT_ERROR,'请登录', url('login/index'));
+        }
+
+        // 设置登录用户信息
+        if(session('user_info.id') > 0)
+        {
+            $this->assign('user_info', session('user_info'));
+        }
+    }
+
+
+
+
+
+}

+ 33 - 0
Index.php

@@ -0,0 +1,33 @@
+<?php
+namespace app\home\controller;
+
+/**
+ * 前端首页控制器
+ */
+class Index extends IndexBase
+{
+    
+    // 首页
+    public function index()
+    {
+        
+        return $this->fetch('reg');
+    }
+    
+    // 详情
+    public function details($id = 0)
+    {
+        
+        $where = [];
+        
+        !empty((int)$id) && $where['a.id'] = $id;
+        
+        $data = $this->logicArticle->getArticleInfo($where);
+        
+        $this->assign('article_info', $data);
+        
+        $this->assign('category_list', $this->logicArticle->getArticleCategoryList([], true, 'create_time asc', false));
+        
+        return $this->fetch('details');
+    }
+}

+ 34 - 0
common.php

@@ -0,0 +1,34 @@
+<?php
+// +---------------------------------------------------------------------+
+// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
+// +---------------------------------------------------------------------+
+// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
+// +---------------------------------------------------------------------+
+// | Author     | Bigotry <3162875@qq.com>                               |
+// +---------------------------------------------------------------------+
+// | Repository | https://gitee.com/Bigotry/OneBase                      |
+// +---------------------------------------------------------------------+
+
+/**
+ * 应用公共(函数)文件
+ */
+
+use think\Db;
+use think\Response;
+use think\exception\HttpResponseException;
+
+
+// +---------------------------------------------------------------------+
+// | 系统相关函数
+// +---------------------------------------------------------------------+
+
+/**
+ * 清除登录 session
+ */
+function clear_login_session()
+{
+
+    session('user_info', null);
+}
+
+

+ 44 - 0
config.php

@@ -0,0 +1,44 @@
+<?php
+// +---------------------------------------------------------------------+
+// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
+// +---------------------------------------------------------------------+
+// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
+// +---------------------------------------------------------------------+
+// | Author     | Bigotry <3162875@qq.com>                               |
+// +---------------------------------------------------------------------+
+// | Repository | https://gitee.com/Bigotry/OneBase                      |
+// +---------------------------------------------------------------------+
+
+// 前端配置文件
+
+empty(STATIC_DOMAIN) ? $static = [] :  $static['__STATIC__'] = STATIC_DOMAIN . SYS_DS_PROS . SYS_STATIC_DIR_NAME;
+
+return [
+
+    //'template' => ['layout_on' =>  true, 'layout_name' => 'layout'],
+
+    // 视图输出字符串内容替换
+    'view_replace_str' => $static,
+
+    // +----------------------------------------------------------------------
+    // | 验证码配置
+    // +----------------------------------------------------------------------
+    'captcha'  => [
+        // 验证码字符集合
+        'codeSet'  => '123456789',
+        // 验证码字体大小(px)
+        'fontSize' => 35,
+        // 是否画混淆曲线
+        'useCurve' => false,
+        // 验证码图片高度
+        'imageH'   => 80,
+        // 验证码图片宽度
+        'imageW'   => 320,
+        // 验证码位数
+        'length'   => 4,
+        // 验证成功后是否重置
+        'reset'    => true
+    ],
+
+
+];