FILE上传图片
来源:互联网 发布:二手车价格评估软件 编辑:程序博客网 时间:2024/05/22 08:12
<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)" onclick="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>
- FILE上传图片
- html5 file上传图片
- file上传图片功能
- file上传图片功能
- file上传图片功能
- 上传图片file优化
- input file上传图片
- input file上传图片
- file 图片上传
- File 上传图片的预览
- input file上传图片预览
- input=file 上传图片
- input file美化 --上传图片
- input file 上传图片预览
- input file上传图片预览
- jquery html5 file 上传图片显示图片
- ExtJs 入门教程十三[上传图片:File]
- AFNetWorking文件上传Data File图片 文件.
- 佛祖保佑 永无bug
- Java虚拟机的启动与程序的运行
- iOS_导入libxml2.2框架后,找不到<libxml/tree.h>的解决办法
- 资源收藏:扁平化风格的图标
- BZO3065 带插入区间K小值
- FILE上传图片
- 谷歌眼镜的技术原理
- 读研的资格。。。。
- poj1459 最大流 Power Network
- Ticket 服务: 一种经济的分布式唯一主键生成方案
- 细说linux挂载——mount,及其他
- UVa 348 Optimal Array Multiplication Sequence (DP 最优矩阵链乘)
- Linux netstat命令详解
- 5-linux学习笔记之-----curses