php 上传图片

public static function mkFolder($path)
{
if(!is_readable($path))
{
is_file($path) or mkdir($path);
}
}

  


public function Upload_上传图片()
    {
        $path = '/Upload/HuaHua/'.date("Ymd");
        Lee::mkFolder($_SESSION["APP_ROOT"].$path);
        $img = $_REQUEST['question_pic'];
        $img = str_replace('data:image/jpeg;base64,', '', $img);
        $img = str_replace(' ', '+', $img);
        $data = base64_decode($img);
        $file = $path .'/'.uniqid().'.jpeg'; 
        $success = file_put_contents($_SESSION["APP_ROOT"].$file, $data);
        if($success)
        {
             return  $_SESSION["STATIC_ROOT"].$file;
        }
        else
        {
            return null;
        }
    }
    
 
原文地址:https://www.cnblogs.com/CyLee/p/5559740.html