⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uploadpicok.jsp

📁 LyNews凌云新闻系统
💻 JSP
字号:
<%
/*##################################################################**
**#  项目名称:LyNews『凌云新闻』                                  #**
**#                                                                #**
**#  程序开发: teddy 『星语凌』                                    #**
**#                                                                #**
**#  版权所有: 凌云创作室 (原流星电脑工作室)                       #**
**#                                                                #**
**#  主页地址: http://www.lybbs.com                                #**
**#            http://www.lybbs.net                                #**
**#  电邮地件: horseye@sina.com                                    #**
**#                                                                #**
**##################################################################*/
%>
<%@include file="config.jsp"%>
<%@include file="getsession.jsp"%>
<%@page contentType="text/html;charset=GBK"%>
<jsp:useBean id="smartUpload" scope="page" class="com.lyforum.upload.SmartUpload" />
<%
Factory factory = Factory.getInstance();
NewsConfigFactory newsConfigFactory = factory.getNewsConfigFactory();
UploadFactory uploadFactory = factory.getUploadFactory();
Upload upload = factory.getUpload();

smartUpload.initialize(pageContext);
smartUpload.upload();

com.lyforum.upload.File uploadFile=null;
int fileCount=smartUpload.getFiles().getCount();
int maxUpload=1000;// size must < 1000K
int uploadFileSize=0;
String uploadFileExt="";

NewsConfig newsAd=newsConfigFactory.getNewsConfig();
String allowUploadExt=newsAd.getAllowUploadExt();
String[] allowUploadExtArray=allowUploadExt.split(",");

//windows
//String uploadRealPath="D:/web/glnews/upload/";
//linux
String uploadRealPath="/var/www/html/glnews/upload/";
String uploadFileName="";

while(fileCount--!=0) {
  uploadFile=smartUpload.getFiles().getFile(fileCount);
  if(!uploadFile.isMissing()) {
    uploadFileSize=uploadFile.getSize();
    uploadFileExt=uploadFile.getFileExt().toLowerCase();
    boolean flag=false;
    for(int i=0;i<allowUploadExtArray.length;i++) {
      if(allowUploadExtArray[i].equals(uploadFileExt))
        flag=true;
    }
    if(uploadFileSize>maxUpload*1000)
      throw new Exception("上传图片不得超过 "+maxUpload+" KB!");
    else if(uploadFileExt.equals("") || !flag)
      throw new Exception("文件的类型不支持上传!支持上传的文件类型有:"+allowUploadExt);
    else {
      String tempSTR="";
      int width=0,
          height=0,
          border=0;
      String alt="",
             link="",
             position="";
      tempSTR=smartUpload.getRequest().getParameter("width"+fileCount);
      if(tempSTR!=null && !tempSTR.equals(""))
        width=Integer.parseInt(tempSTR);
      tempSTR=smartUpload.getRequest().getParameter("height"+fileCount);
      if(tempSTR!=null && !tempSTR.equals(""))
        height=Integer.parseInt(tempSTR);
      tempSTR=smartUpload.getRequest().getParameter("border"+fileCount);
      if(tempSTR!=null && !tempSTR.equals(""))
        border=Integer.parseInt(tempSTR);
      tempSTR=smartUpload.getRequest().getParameter("alt"+fileCount);
      if(tempSTR!=null && !tempSTR.equals(""))
        alt=tempSTR;
      tempSTR=smartUpload.getRequest().getParameter("link"+fileCount);
      if(tempSTR!=null && !tempSTR.equals(""))
        link=tempSTR;
      tempSTR=smartUpload.getRequest().getParameter("position"+fileCount);
      if(tempSTR!=null && !tempSTR.equals(""))
        position=tempSTR;
      long currentTime=System.currentTimeMillis();
      uploadFileName=currentTime+"_"+fileCount+"."+uploadFileExt;

      upload.setWidth(width);
      upload.setHeight(height);
      upload.setBorder(border);
      upload.setSaveAt(currentTime);
      upload.setAlt(alt);
      upload.setLink(link);
      upload.setPosition(position);
      upload.setFileName(uploadFileName);
      uploadFactory.addUpload(upload);

      uploadFile.saveAs(uploadRealPath+uploadFileName);
    }
  }
}
%>
<HTML>
<HEAD>
<title>图片上传成功</title>
<link rel="stylesheet" href="../inc/admin.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<BODY leftmargin="0" bottommargin="0" rightmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor="#DDEEFF">
<br><br>
<center><b>已经成功上传了图片。</b></center>
<br>
<center><a href=uploadPic.jsp>我想要继续上传图片。</a></center>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -