flash上传头像插件使用说明
2015-02-11 13:46
351 查看
组件下载地址:
flash上传头像剪裁预览组件_头像上传插件 - 免费开源
http://www.hdfu.net/
参数说明:
imgUrl:默认图片地址
uploadUrl:接收图片url
uploadSrc = true,是否上传源图
showCame = true,是否显示摄像头
pCut:=162|162,裁剪框大小(自定义)
pSize=162|162,预览保存图片大小
pData=162|162保存图片大小
保存1张图片时:pSize = 162|162&pData=162|162
保存2张图片时:pSize = 162|162|48|48&pData=162|162|48|48
例子:
前端:
<!DOCTYPE html>
<html lang="zh-CN">
<%@ page pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String _path = request.getContextPath();
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>flash上传头像组件演示</title>
<script type="text/javascript">
//上传成功,js回调函数
function uploadevent(status,picUrl,callbackdata){
alert(picUrl); //后端存储图片
// alert(callbackdata);
status += '';
switch(status){
case '1':break;
case '-1':window.location.reload(); break;
default:window.location.reload();
}
}
</script>
</head>
<body>
<div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
width="650" height="450" id="myMovieName">
<param name="movie" value="<%=_path%>/avatar.swf">
<param name="quality" value="high">
<param name="bgcolor" value="#FFFFFF">
<param name="flashvars" value="imgUrl=<%=_path%>/img/user_logo.jpg&uploadUrl=<%=_path%>/logo/upload&uploadSrc=false&pCut=162|162&pSize=162|162&pData=162|162&showBe=false" />
<embed src="<%=_path%>/avatar.swf" quality="high" bgcolor="#FFFFFF" width="650" height="450" wmode="transparent"
flashvars="imgUrl=<%=_path%>/img/user_logo.jpg&uploadUrl=<%=_path%>/logo/upload&uploadSrc=false"
name="myMovieName" align="" type="application/x-shockwave-flash" allowScriptAccess="always"
pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>
</object>
</div>
</body>
</html>
后台(java):
@RequestMapping(value="/logo/upload", method=RequestMethod.POST)
public @ResponseBody void uploadCompanyLogo(PrintWriter printWriter, HttpServletRequest request, HttpServletResponse response){
String userId = request.getSession().getAttribute("userId").toString();
String filename = "logo.jpg";
String logoPath = "D:/userLogo/" + userId;
String pic = request.getParameter("pic1"); //保存原图时,此时接收参数应是pic;尺寸1则是pic1,尺寸2则是pic2 。。。
File file = null;
File directory = null;
try {
directory = new File(logoPath);
if (!directory.exists()){
directory.mkdirs();
}
if(!pic.equals("")&&pic!=null){
file = new File(logoPath+"/"+filename);
FileOutputStream fout = null;
fout = new FileOutputStream(file);
fout.write(new BASE64Decoder().decodeBuffer(pic));
fout.close();
}
}
catch (IOException e) {
if (file.exists()){
file.delete();
}
}
printWriter.write("{\"status\":1,\"picUrl\":\""+filename+"\"}");
printWriter.flush();
printWriter.close();
}
flash上传头像剪裁预览组件_头像上传插件 - 免费开源
http://www.hdfu.net/
参数说明:
imgUrl:默认图片地址
uploadUrl:接收图片url
uploadSrc = true,是否上传源图
showCame = true,是否显示摄像头
pCut:=162|162,裁剪框大小(自定义)
pSize=162|162,预览保存图片大小
pData=162|162保存图片大小
保存1张图片时:pSize = 162|162&pData=162|162
保存2张图片时:pSize = 162|162|48|48&pData=162|162|48|48
例子:
前端:
<!DOCTYPE html>
<html lang="zh-CN">
<%@ page pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String _path = request.getContextPath();
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>flash上传头像组件演示</title>
<script type="text/javascript">
//上传成功,js回调函数
function uploadevent(status,picUrl,callbackdata){
alert(picUrl); //后端存储图片
// alert(callbackdata);
status += '';
switch(status){
case '1':break;
case '-1':window.location.reload(); break;
default:window.location.reload();
}
}
</script>
</head>
<body>
<div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
width="650" height="450" id="myMovieName">
<param name="movie" value="<%=_path%>/avatar.swf">
<param name="quality" value="high">
<param name="bgcolor" value="#FFFFFF">
<param name="flashvars" value="imgUrl=<%=_path%>/img/user_logo.jpg&uploadUrl=<%=_path%>/logo/upload&uploadSrc=false&pCut=162|162&pSize=162|162&pData=162|162&showBe=false" />
<embed src="<%=_path%>/avatar.swf" quality="high" bgcolor="#FFFFFF" width="650" height="450" wmode="transparent"
flashvars="imgUrl=<%=_path%>/img/user_logo.jpg&uploadUrl=<%=_path%>/logo/upload&uploadSrc=false"
name="myMovieName" align="" type="application/x-shockwave-flash" allowScriptAccess="always"
pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>
</object>
</div>
</body>
</html>
后台(java):
@RequestMapping(value="/logo/upload", method=RequestMethod.POST)
public @ResponseBody void uploadCompanyLogo(PrintWriter printWriter, HttpServletRequest request, HttpServletResponse response){
String userId = request.getSession().getAttribute("userId").toString();
String filename = "logo.jpg";
String logoPath = "D:/userLogo/" + userId;
String pic = request.getParameter("pic1"); //保存原图时,此时接收参数应是pic;尺寸1则是pic1,尺寸2则是pic2 。。。
File file = null;
File directory = null;
try {
directory = new File(logoPath);
if (!directory.exists()){
directory.mkdirs();
}
if(!pic.equals("")&&pic!=null){
file = new File(logoPath+"/"+filename);
FileOutputStream fout = null;
fout = new FileOutputStream(file);
fout.write(new BASE64Decoder().decodeBuffer(pic));
fout.close();
}
}
catch (IOException e) {
if (file.exists()){
file.delete();
}
}
printWriter.write("{\"status\":1,\"picUrl\":\""+filename+"\"}");
printWriter.flush();
printWriter.close();
}
相关文章推荐
- 上传文件插件 Uploadify使用说明 转
- 改写BlogEngine.NET头像上传实现方式(使用baidu.flash.avatarMaker)
- [Bootstrap-插件使用]Jcrop+fileinput组合实现头像上传功能实例代码
- 关于使用flash上传插件uploadify出现的问题
- 上传插件 plupload使用说明
- jQuery上传插件-uploadify3.1使用说明
- 强大的flash头像编辑上传插件(已更新至2.3)
- 【Bootstrap-插件使用】Jcrop+fileinput组合实现头像上传功能
- yii2 之图片上传插件fileinput使用说明
- 使用Flash结合PHP实现头像的无刷新上传与裁剪
- 使用jquery的imagecropper插件做用户头像上传 兼容移动端
- html5文件上传插件,附带使用说明
- Bootstrap文件(图片)上传插件File Input进阶使用说明
- JQuery批量上传插件Uploadify使用详解及参数说明
- 多项目上传文件解决方案之:Flash插件使用
- 简单测试实现 博客园的头像上传功能 使用插件jquery jcrop+fineupload
- 上传文件插件 Uploadify使用说明
- 前端插件——头像截图上传插件的使用(带后台)
- jquery.uploadify上传插件HTML5版中文api使用说明
- 强大的flash头像上传插件(支持旋转、拖拽、剪裁、生成缩略图等)