html上传图片

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div class="form-group">
<label for="touxiang" class="col-sm-2 control-label"> 个人照片 </label>
<div class="col-sm-6">
<input type="hidden" name="attrimg" id="attrimg" value="">
<div id="yiimg" class="imimglist"></div>
<div>
<label for="image_file" id="showerror">上传图片,选择或拍照</label>
</div>
<input type="file" accept="image/*" class="button block" name="image_file" id="image_file" />
<div class="preview" id="preview"></div>
<canvas style="display:none;" id="oldimg"></canvas>
<canvas style="display:none;" id="myCanvas"></canvas>
<script type="text/javascript">
$(document).ready(function(){
$("#image_file").upload({posturl:"/newsupload.php"},{ttid:1,owidth:400,oheight:400},function(e){
$('#showerror').html('上传完成!');
var r= e.target.responseText.split("|");
if(r[0]!='error')
{
$("#yiimg").html("<img src='"+r[1]+"' width=45 height=45>");
$("#preview").html('');
$("#attrimg").val(r[0]);
$('#showerror').html('上传完成!请继续添加其它信息。');
}else{
$('#showerror').html(r[1]);
}
});


});
</script>
</div>
</div>
</body>
</html>
posted @ 2021-07-08 09:17  臭笑  阅读(778)  评论(0编辑  收藏  举报