Discuz X3.4保存头像代码

暂无标签

摘取的片段

$uid = sprintf("%09d",abs(intval($_G['uid'])));
$filepath = DISCUZ_ROOT."/uc_server/data/avatar/".substr($uid, 0, 3)."/".substr($uid, 3, 2)."/".substr($uid, 5, 2)."/";
$filename = substr($uid, -2)."_avatar_big.jpg";
if(!is_dir($filepath))mkdir($filepath,0755,TRUE);
$imgstr = $_POST['img'];
$imgdata = substr($imgstr,strpos($imgstr,",") + 1);
$decodedData = base64_decode($imgdata);
file_put_contents($filepath.$filename,$decodedData);