Skip to content

Instantly share code, notes, and snippets.

@hewwcn
Created April 25, 2013 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hewwcn/5457215 to your computer and use it in GitHub Desktop.
Save hewwcn/5457215 to your computer and use it in GitHub Desktop.
////目标文件,源文件,目标文件坐标,源文件坐标,目标文件宽高,源宽高
imagecopyresampled($new_image, $img_obj, 0, 0, 0, 0, $new_w, $new_h, $img_info[0], $img_info[1]);
imagedestroy($img_obj);
ob_start();
imagejpeg($new_image, NULL, 95);
$out_img = ob_get_contents();
ob_end_clean();
$s = new SaeStorage();
//第一个参数为storage的名称
$img_url = $s->write( 'avatar' , $cur_uid.'.jpg', $out_img);
//注释掉了又拍云上传的代码,提取了操作数据库的代码
if($cur_user['avatar']!=$cur_user['id']){
$DBM = new DB_MySQL;
$DBM->connect($servername_m, $dbport, $dbusername, $dbpassword, $dbname);
if($DBM->unbuffered_query("UPDATE yunbbs_users SET avatar='$cur_uid' WHERE id='$cur_uid'")){
$cur_user['avatar'] = $cur_user['id'];
$MMC->set('u_'.$cur_uid, $cur_user, 0, 600);
}else{
$tip2 = '数据保存失败,请稍后再试111';
}
}
unset($out_img);
$av_time = $timestamp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment