<?php
namespace app\bsadmin\controller;
use app\common\UploadFile;
use think\facade\Session;
class Publics extends Base
{
    public function uploads()
    {
        $ret=UploadFile::upload(Session::get('AdminUser.uid','bsadmin'));
        return json($ret);
    }
    public function getImgByPath()
    {
    	$G=request()->get();
    	$path=str_replace('//','/',public_path().config('web.logo'));
	   	if(!empty($G['path']))
    		$path=$G['path'];
    	if(!@file_exists($path))
    		return null;
		$info=getimagesize($path);
		$imgExt = image_type_to_extension($info[2], false);
		$fun = "imagecreatefrom{$imgExt}";
		$imgInfo = $fun($path);
		header('Content-Type:'.$info['mime']);
		$quality = 100;
		if($imgExt == 'png') $quality = 9;
		$getImgInfo = "image{$imgExt}";
		$getImgInfo($imgInfo, null, $quality);
		imagedestroy($imgInfo);
		die;
    }
}
