<?
		$picstyle = "jpg gif png jpeg";
		$iserror = 0;
		
		$listuser -> checklogin($_SESSION["member"]->uid);

		//上传是否成功
		if($iserror == 0 and $act == "ok"){
				foreach($_FILES["userfile"]["error"] as $fileerror){
						if($fileerror == 1){
								$iserror = 1;
								$url = array("act"=>"");
								$tourl = URL_user_photo($url);
								$pagecontent = "<b>上传失败：</b><br/>";
								$pagecontent .= "附件大小超过服务器默认设置".ini_get("upload_max_filesize")."正在返回，请稍后！<br/>";
						}
				}
		}
		//附件格式判断
		if($iserror == 0 and $act == "ok"){
				foreach($_FILES["userfile"]["name"] as $filename){
						$filetypedate1 = explode(".",$filename);
						$filetypedate2 = count($filetypedate1)-1;
						$filetype = $filetypedate1[$filetypedate2];
						$systemtype = explode(" ",$picstyle);
						if(!in_array($filetype,$systemtype)){
								$iserror = 1;
								$url = array("act"=>"");
								$tourl = URL_user_photo($url);
								$pagecontent = "<b>上传失败：</b><br/>";
								$pagecontent .= "您上传的附件".$filename."格式错误，只支持上传".$picstyle."正在返回，请稍后！<br/>";
						}
				}
		}
		//附件入库
		if($iserror == 0 and $act == "ok"){
				$attachdate["name"] = $_FILES["userfile"]["name"][0];
				$filenamedate1 = explode(".",$_FILES["userfile"]["name"][0]);
				$filenamedate2 = count($filenamedate1)-1;
				$attachdate["postfix"] = $filenamedate1[$filenamedate2];
				$filenamedate1 = "";
				$filenamedate2 = "";
				$attachdate["size"] = $_FILES["userfile"]["size"][0];
				
				//头像入库
				$db->query("UPDATE ".JIEQI_DB_PREFIX."_system_users SET avatar = 2 WHERE uid=".$_SESSION["member"]->uid);//用户头像
				$_SESSION["member"]->avatar	= 2;//用户头像
				
				/*保存到SAE STORAGE服务器*/
				
				$upfile = PRO_ROOT."/files/system/avatar/0/".$_SESSION["member"]->uid.".".$attachdate["postfix"];
				move_uploaded_file($_FILES["userfile"]["tmp_name"][0],$upfile);
				$smallImg = PRO_ROOT."/files/system/avatar/0/".$_SESSION["member"]->uid."_s.".$attachdate["postfix"];//缩略图名称
				
				$toW = 100; // 生成图片的宽度 
				$toH = 100; // 生成图片的高度 
				ImageResize($upfile,$toW,$toH,$smallImg);
				
				$url = array();
				$tourl = URL_user_my_space($url);
				$pagecontent = "<b>温馨提示：</b><br/>";
				$pagecontent .= "您的头像上传成功<br/>";
		}
		
		if($iserror == 0 and $act != "ok"){
				$smartydate = array("pagetitle" => "修改头像",
													"attachtype" => $picstyle,
											);
				$tplpath = "user/photo.tpl";
		}else{
				$smartydate = array("pagetitle" => "修改头像",
														"pagecontent" => $pagecontent,
														"tourl" => $tourl,
														"redirecturl" => $tourl,
														);
														
				$tplpath = "public.tpl";
		}
?>