<?php

namespace app\admin\controller;

use app\model\Banner as ModelBanner;
use app\BaseController;
use app\Request;
use app\exception\ErrorMsg;
use think\facade\Validate;
use app\common\arw\adjfut\src\Excel;
use app\common\arw\adjfut\src\UploadFile;
use think\facade\Db;
use think\facade\Env;

class Common extends BaseController
{

    /**
     * 上传图片
     */
    public function uploadImg(Request $request)
    {
        $dirName = $request->param('dirName');

        $upload = new UploadFile('uploads', 'file');
        $path = $upload->putFile($dirName . 'Img');
        return [
            'code' => 0,
            'data' => [
                "name" => $path,
                "url" => "/uploads/" . $path,
            ],
            'msg' => '上传成功！'
        ];
    }

    /**
     * 上传文件
     */
    public function uploadFile(Request $request)
    {
        $dirName = $request->param('dirName');

        $upload = new UploadFile('uploads', 'file');
        $path = $upload->putFile($dirName . 'File');
        return [
            'code' => 0,
            'data' => [
                "name" => $path,
                "url" => "/uploads/" . $path,
            ],
            'msg' => '上传成功！'
        ];
    }
}
