<?php

namespace app\admin\controller;

header('Content-Type:text/html; charset=utf-8');

use think\Controller;

class Upload extends Common {
    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('upload');
    }

    //附件首页
    public function index(){
        $data=model('upload')->field('id,file_size,create_time,status,filename,file_path,suffix')->select()->toArray();
        $this->assign('data',$data);
        $this->assign('page','');
        return $this->fetch();
    }

    public function upimage(){
        return $this->model->upfile('images');
    }
    public function upimages(){
        return $this->model->upfiles('images');
    }
    public function upfile(){
        return $this->model->upfile('files');
    }

    //wangEditor 上传
    public function wangEditor_upimage(){
        $result =  $this->model->upfile('Editor','file',false);
        if($result['code'] == 200){
            $data = array('errno'=>0,'msg'=>'上传成功','data'=>array($result['path']));
        }else{
            $data = array('errno'=>1,'msg'=>$result['msg']);
        }
        return json_encode($data);
    }

}