<div class="loadfile" id="loadfilediv">
<h4> <i:i18n type="agenthousemanager.agenthouserfileimage" text="上传图片"/></h4><hr/>
<form id="fileuploadID" action="${path}/Agent/getimagefile" name="fileuploadID" method="post" enctype="multipart/form-data" >
<div class="uploader white">
<div id="imagefile">
<input type="hidden" id="typeId" name="typeId" value=""/>
<input type="hidden" id="houseType" name="houseType" value="1"/>
<input type="hidden" id="houseId" name="houseId" value="${id}"/>
<input type="hidden" id="useTypeId" name="useTypeId" value=""/>
<input type="text" class="filename" readonly="readonly"/>
<input type="button" name="file" class="button" value=<i:i18n type="agenthousemanager.agenthouserfileimage" text="选择图片"/>/>
<input type="file" id="fileToUpload" name="fileToUpload" size="30"/>
</div>
</div>
<div class="change-btn commonbtn">
<a href="javascript:canceluploaduserphoto()" class="fl filebtn"><i:i18n type="agenthousemanager.agenthouserfileimage" text="取消"/></a>
<a href="javascript:void(0)" οnclick="uploaduserphoto()" class="fl filebtn"><i:i18n type="agenthousemanager.agenthouserfileimage" text="上传"/></a>
</div>
</form>
</div>
<script type="text/javascript">
$("input[type=file]").change(function(){$(this).parents(".uploader").find(".filename").val($(this).val());});
$("input[type=file]").each(function(){
if($(this).val()==""){$(this).parents(".uploader").find(".filename").val("<i:i18n type='agenthousemanager.agenthouserfileimage' text='您还没有选择文件...'/>");}
});
function uploaduserphoto(){
var img=null;
var imggeshi=fileuploadID.fileToUpload.value;
if(imggeshi==""){
alert("<i:i18n type='agenthousemanager.agenthouserfileimage' text='请选择图片文件!'/>");
return false;
}
var point=imggeshi.lastIndexOf(".");
var imgtype=imggeshi.substr(point);
if(imgtype==".jpg" || imgtype==".gif" || imgtype==".png"
|| imgtype==".jpeg" || imgtype==".bmp"
|| imgtype==".JPEG" || imgtype==".BMP" || imgtype==".JPG"
|| imgtype==".GIF" || imgtype==".PNG"){
img=document.createElement("img");
if(img.fileSize>2048*1536){
alert("<i:i18n type='agenthousemanager.agenthouserfileimage' text='图片大小不能超过3M!'/>");
return false;
}
}else{
alert("<i:i18n type='agenthousemanager.agenthouserfileimage' text='图片格式有误!支持上传格式为jpg,gif,png,jpeg,bmp'/>");
return false;
}
//图片上传
$('#fileuploadID').ajaxSubmit({
complete: function(xhr) {
var json = eval('(' + xhr.responseText + ')');
var view = json.root;
var typeId = view.typeId;
//var img = $("<img style='width: 100px; height: 50px;'/>");
//img.attr("src",view.urlPrefix+view.webPath);
//var imgurl = $("<input type='hidden' id='filePath' name='filePath'/>");
//imgurl.attr("value",view.webPath);
//$("#imagesplay_"+typeId).append(img);
//$("#imagefile").append(imgurl);
var img = "<img style='width: 100px; height: 50px;' src='"+view.urlPrefix+view.webPath+"' />";
var delbt='<a class="delect-btn" href="javascript:getdeleteimg('+view.picId+')"></a>';
var content="<div class='delete_img' id="+view.picId+">"+img+delbt+"</div>";
$("#imagesplay_"+typeId).find("a[class='agent-btn']").before(content);
$("#loadfilediv").css("display","none");
$("#fileToUpload").val("");
$("#imagefile .filename").val("");
alert("<i:i18n type='agenthousemanager.agenthouserfileimage' text='图片保存成功'/>");
}
});
}
</script>