text-align: center;
}
.a-upload input {
position: absolute;
font-size: 100px;
right:0;
top: 0;
opacity: 0;
filter: alpha(opacity=0);
cursor: pointer
}
js,css弹出层样式
/***遮罩层样式**/
.wrap-overlayer{
position: fixed;
left: 0;
top:0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.3);
z-index:10;
display:none;
}
/**上传组件样式**/
.main-layer{
position:absolute;
left:50%;top:50%;
background-color: #fff;
width:350px;
height: 150px;
}后台部分代码
@RequestMapping(value="/upload.do",method=RequestMethod.POST)
private void fildUpload(@RequestParam(value="file",required=false) MultipartFile file,
HttpServletRequest request,HttpServletResponse resp)throws Exception{
//获得物理路径webapp所在路径
String pathRoot = request.getSession().getServletContext().getRealPath("");
String path="";
if(!file.isEmpty()){
//生成uuid作为文件名称
String uuid = UUID.randomUUID().toString().replaceAll("-","");
//获得文件类型(可以判断如果不是图片,禁止上传)
String contentType=file.getContentType();
//获得文件后缀名称
String imageName=contentType.substring(contentType.indexOf("/")+1);
path="/images/"+uuid+"."+imageName;
file.transferTo(new File(pathRoot+path));
}
request.setAttribute("imagesPath", path);
} 以上所述是小编给大家介绍的jQuery自定义图片上传插件实例代码,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的,在此也非常感谢大家对软件开发网网站的支持!










