关闭

头像图片剪切flash工具 swfobject

标签: 头像图片剪切flash工具
293人阅读 评论(0) 收藏 举报

1.HTML页面信息


 <div class="line"></div>
 <div class="user_package mb20">
		<div class="user_tit">
			<div class="l_tit"><span>修改头像<#-- 修改头像[flash] --></span></div>
		</div>
		<div class="user_base1">
<#--头像信息页面-->
<#if requestAttributes.cmsUser?has_content>
	<div class="account-bd fix" style="margin-left: 0px;margin-right: 20px;overflow: hidden;margin-bottom: 20px;">
	  	<div class="fix photo-content">
			<div class="photo-list">
	  			<div id="altContent"></div>
				<script type="text/javascript" src="/pinkwood/shangyunyijia/flashcutting/swfobject.js"></script>
				<script type="text/javascript">
					function uploadevent(status){
					     status += '';
						 switch(status){
						 
							case '1':
								alert('${StringUtil.wrapString(uiLabelMap.MtjwbUploadSuccess)}');
							break;
				
							case '2':
								if(confirm('js call upload')){
									return 1;
								}else{
									return 0;
								}
							break;
				
							case '-1':
								window.location.href = "${(requestAttributes.mtjUrl)!}/set/basic/<#if requestAttributes.cmsUser?has_content>${(requestAttributes.cmsUser.userId)!}</#if>";
							break;
							
							case '-2':
								alert('upload failed!');
								window.location.href = "#";
							break;
				
							default:
								alert(typeof(status) + ' ' + status);
						} 
					}
					var flashvars = {
					  "jsfunc":"uploadevent",
					  "uploadSrc":true,
					  "showBrow":true,
					  "showCame":true,
					  "pSize":"300|300|180|180|75|75|30|30",
					  "imgUrl":"/pinkwood/shangyunyijia/space-img04.jpg",
					  "uploadUrl":"${(requestAttributes.mtjUrl)!}<@ofbizUrl>uploaderEvent?action=uploadavatar</@ofbizUrl>"
					};
				
					var params = {
						menu: "false",
						scale: "noScale",
						allowFullscreen: "true",
						allowScriptAccess: "always",
						wmode:"transparent",
						bgcolor: "#FFFFFF"
					};
				
					var attributes = {
						id:"FaustCplus"
					};
				
					swfobject.embedSWF("/pinkwood/shangyunyijia/flashcutting/avatar.swf", "altContent", "650", "500", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
				</script>
	  		</div>
	  	</div>
		
	</div>
<#else>
	<div class="photo-uploading">
		<a class="upload-bt" href="${(requestAttributes.mtjUrl)!}/set/avatarbasic/${(requestAttributes.cmsUser.userId)!}">
			<em><i class="icon"></i>${uiLabelMap.MtjWBUInfoTip}<span>${uiLabelMap.MtjWBUInfoTypeTip}</span></em>
		</a>
		<a class="upload-bt" onclick="refreshVCode();openPopupBox_UserLogin();">
			<em><i class="icon"></i>${uiLabelMap.MtjWbSpaceLoginTip}<span>${uiLabelMap.MtjWbLogin}</span></em>
		</a>
	</div>
</#if>
	</div>
</div>

2.java处理上传的图片信息


<span style="white-space:pre">	</span>/**
	 * 会员头像上传管理
	 * @param request
	 * @throws Exception
	 */
	private static void uploadavatar( HttpServletRequest request ) throws Exception {
		Map<String,Object> context = FastMap.newInstance() ;
		Delegator delegator = ( Delegator ) request.getAttribute("delegator") ;
		GenericValue userLogin = ( GenericValue ) request.getSession().getAttribute("userLogin");
		List<GenericValue> cmsUserList = delegator.findByAnd("CmsUsers",UtilMisc.toMap("userLoginId", userLogin.getString("userLoginId")) ) ;
		GenericValue cmsUser = EntityUtil.getFirst(cmsUserList);
		InputStream ins = null ;
		
		/**获取图片信息**/
		//String pic=request.getParameter("pic");
		String pic1=request.getParameter("pic1");
		/*String pic2=request.getParameter("pic2");
		String pic3=request.getParameter("pic3");*/
		
		try {
			//取得图片流信息
			byte[] inp = new BASE64Decoder().decodeBuffer(pic1);
			
			String fileName= request.getHeader("fileName")!=null?request.getHeader("fileName"):"uploadtmp.jpg";
			ByteBuffer fileBytes = ByteBuffer.wrap(inp) ;
			context.put("uploadFile", fileBytes);
			context.put("_uploadFile_fileName", fileName) ;
			AbstractResourceHandler rh = AbstractResourceHandler.getInstance( AbstractResourceHandler.UPALIYUN_CMS_RH ) ;
			String imagePath=rh.writeFile(delegator, context, "userAvatar_Original", cmsUser.getString("userId")) ;
			if(UtilValidate.isNotEmpty(imagePath)){
				cmsUser.set("avatarPath", imagePath);
				cmsUser.store();
				request.setAttribute("status", "1");
			}
		} catch (Exception e) {
			Debug.logError(e, e.getMessage(), module ) ;
		} finally{
			if( null != ins ) {
				ins.close() ;
			}
		}
	}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:6878次
    • 积分:207
    • 等级:
    • 排名:千里之外
    • 原创:13篇
    • 转载:3篇
    • 译文:1篇
    • 评论:0条
    文章分类