upLoaded1.jsp
上传用户:u_thks
上传日期:2022-07-31
资源大小:1910k
文件大小:5k
- <%@ page language="java" contentType="text/html;charset=UTF-8"
- session="true" errorPage="err.jsp" %>
- <%@ include file="../GVinc/gvImport.jsp" %>
- <jsp:useBean id="cup" scope="request" class="com.gamvan.club.user.ClubUserParameter"/>
- <jsp:useBean id="ud" scope="request" class="com.gamvan.club.manage.UpLoadDataBase"/>
- <jsp:useBean id="imo" scope="page" class="com.gamvan.image.ImageOperate" />
- <jsp:useBean id="fub" scope="page" class="com.gamvan.fileUpload.FileUpBean" />
- <%
- int userID = 0;
- if(request.getParameter("userID")!=null){
- userID = TypeChange.stringToInt(request.getParameter("userID"));
- }
- if(userID<=0){
- out.print("非法操作!");
- out.close();
- if(true)return;
- }
- if(gvUserID!=userID){
- out.print("非法操作!");
- out.close();
- if(true)return;
- }
- %>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title><%=clubTitle%></title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <link href="../GVimgs/favicon.ico" rel="Bookmark">
- <link rel="icon" href="../GVimgs/favicon.ico" type="image/x-icon" />
- <link rel="shortcut icon" href="../GVimgs/favicon.ico" type="image/x-icon" />
- <link href="../GVinc/main.css" rel="stylesheet" type="text/css" />
- <body>
- <%
- if(gvUserUpfileOpen==2){
- out.print("<font color="#bb0000">您的上载功能已被管理员关闭!</font>");
- out.close();
- if(true) return;
- }
- if(request.getParameter("ccID")!=null){
- ccID = Integer.parseInt(request.getParameter("ccID"));
- }
- String newFileName="";
- if(request.getParameter("ccName")!=null){
- ccName = clubgb.gb(request.getParameter("ccName"));
- }
- newFileName += String.valueOf("gv_" + userID);
-
- FileOperate fo = new FileOperate();
- String fpaths="", vpaths="";
- String fileSavePath=request.getRealPath("") + "\upFiles\club\userHeads\"; //绝对路径
- String fileTempPath=request.getRealPath("") + "\upFiles\temp\"; //存放临时文件的路径。
-
-
- java.util.Calendar now1 = Calendar.getInstance();
- int year=now1.get(Calendar.YEAR);
- //int mon=now.get(Calendar.MONTH);
- //int day=now.get(Calendar.DAY_OF_MONTH);
- fpaths = String.valueOf(year);
- fo.createFolders(fileSavePath,fpaths);
- fileSavePath += fpaths + "\"; //绝对路径
- //out.print(clubUpfileExt.replace("|",","));
- //=============================================
- vpaths = "/upFiles/club/userHeads/"+String.valueOf(year) +"/"; //相对路径
- out.print(gvUserUpfile-gvUserUpfileSize);
- fub.initialize(pageContext);
- fub.setMaxFileSize(40*1024); //最大上传
- fub.setMyFileSize(gvUserUpfile-gvUserUpfileSize); //我的个人空间 单位Kb
- fub.setFileTempPath(fileTempPath); //存放临时文件的路径。
- fub.setFileSavePath(fileSavePath);
- fub.setAllowedType(clubUpfileExt); //允许上传的文件类型
- fub.setNewFileName(newFileName);
- boolean isOK = fub.saveFile();
-
- String fileExt="", oldFileName="", oldFilePath="";
- long fileSizel = 0;
- int fileSize = Integer.parseInt(String.valueOf(fileSizel));
-
- if(!isOK){
- out.print(fub.getMessage());
- out.close();
- if(true) return;
- }else{
- fileExt = fub.getFileExt();
- fileSizel = fub.getFileSize();
- oldFileName = fub.getOldFileName();
- oldFilePath = fub.getOldFilePath();
- try{
- out.print(writeText(newFileName+"."+fileExt, vpaths + newFileName+"."+fileExt, fileExt));
- ud.setCfNewName(newFileName+"."+fileExt); //另存后的新文件名。
- ud.setCfOldName(oldFileName); //来源的原文件名。
- ud.setCfNewPath(vpaths); //另存后路径
- ud.setCfOldPath(oldFilePath);
- ud.setCfExt(fileExt);
- ud.setCfContentType(""); //内容型别。。
- ud.setCfSize(fileSize);
- ud.setCfType((short)1); //代表主题应用 2代表头像应用。
- ud.setCfUseID(-1); //系统头像
- ud.setCfUseTxt("");
- ud.setCfByUser(gvUserName);
- ud.setCfByIp(request.getRemoteAddr());
- ud.setCcID(ccID);
- ud.setCcName("系统头像上传");
- ud.setCfByUserID(gvUserID);
- //try{
- ud.filesAdd();
- //}catch(Exception e){
- //out.print(e.toString());
- //}
- if(!fileExt.equals("gif")){
- imo.setFilePath(fileSavePath);
- imo.shrinkImage(120,0,newFileName+"."+fileExt,newFileName+"."+fileExt);
- }
- out.println(" 上载成功,请点击 提交 按钮,更新社区形象。");
- }catch (Exception e){
- out.println("<b>Wrong selection : </b>" + e.toString());
- out.close();
- if(true)return;
- }
- }
- %>
- <%!
- public String writeText(String fName, String path, String ext){
- String temp;
- temp = "";
- path = path.replace("/upFiles","");
- path = clubUpfileDomain + path;
- temp += "<script language="javascript">";
- temp += "parent.document.Gforms.userPic.value='"+ path +"';";
- temp += "parent.document.images['myHead'].src='"+ path +"';";
- temp += "</script>";
- return temp;
- }
- %>
- </body>
- </html>