<div class="clear10"></div>
<form name="frmedit" id="frmedit" method="post" enctype="multipart/form-data">
	<input type="hidden" name="action" id="action" value="upload" />
	<div class="block mt">
		<div class="blockcontent">
			<div class="c_row cf">
				<div class="row_cover">
					<img src="{?$url_avatar?}" class="avatar bdc" alt="头像">
				</div>
				<div class="row_text">
					<h4></h4>
					<p><input type="file" accept="image/*" class="text" style="width:165px;" name="avatarimage" id="avatarimage" /></p>
					<p class="mt"><button type="button" class="btn btn-primary" id="clksave" name="submit">上传头像</button></p>
				</div>
			</div>
			<ul class="ulrow mts">
				<li class="hot">头像图片格式为 .gif .jpg .jpeg .png ，文件大小不能超过 10M</li>
			</ul>
		</div>
	</div>
</form>
<script>
$(function(){
	var dosave = false;
	$("#clksave").tap(function () {
		if(dosave) return;
		dosave = true;
		var formData = new FormData(document.getElementById("frmedit"));
		$.ajax({
			type: 'POST',
			url: 'avatar.php',
			data: formData,
			processData: false,
			contentType: false,
			dataType: 'json',
			success: function(res){
				if(res.flag==0) {
					dologin = false;
					popTip(res.msg);
				} else {
					popTip('头像保存成功');
					setTimeout(function(){window.location.href='/member/';}, 1000);
				}
			}
		})
    })
})
</script>