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

📄 upload.jsp

📁 JSP新闻发布系统 JSP新闻发布系统
💻 JSP
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="../../../../strroot.jsp"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor=buttonface>
<%
    com.beijingnews.util.UpLoadFile2 upload = new com.beijingnews.util.UpLoadFile2(pageContext);
    boolean isAllow = upload.uploadRenamedFile(512000,"jpg,gif");
    if(!isAllow) {
        out.print("文件上传失败<a href='javascript:history.back(1)'>返回重试</a>");
        return;
    }
    // 得到Request
    com.jspsmart.upload.Request myRequest = upload.getMyRequest();
    int blog_id;
    try{
        blog_id = Integer.parseInt(myRequest.getParameter("blog_id"));
        if(blog_id<1) throw new Exception();
    }catch(Exception e){
        %><script>parent.close();</script><%
        return;
    }

    System.out.println(blog_id);

    String url = myRequest.getParameter("imgurl");
    if(url == null) {
        url = "";
        String bid = ""+blog_id;
        int bidLen = 8-bid.length();
        for(int i=0;i<bidLen;i++) {
            bid = "0" + bid;
        }
        String vPath = strRoot + "blog/blogs/" + bid.substring(0,2) + "/" + bid.substring(2,4) + "/" + bid.substring(4,6) + "/" + bid.substring(6) + "/images/";
        String rPath = application.getRealPath("/") + "blog\\blogs\\" + bid.substring(0,2) + "\\" + bid.substring(2,4) + "\\" + bid.substring(4,6) + "\\" + bid.substring(6) + "\\images\\";

        java.io.File f = new java.io.File(rPath);
        if(!f.exists()) {
            f.mkdirs();
        }

        if(com.beijingnews.util.FolderLength.getSize(rPath)/1024 >= (1024)) {
            %>您的上传目录已满<%
            return;
        }

        boolean isUploaded = upload.saveFile(rPath);

        if(!isUploaded) {
            out.print("文件上传失败<a href='javascript:history.back(1)'>返回重试</a>");
            return;
        }

        // 得到文件名
        url = vPath+upload.getFileName();
    }

%>

<script language="javascript">
<!--
        parent.opener.InsertImg2("<%=url%>");
        parent.close();
-->
</script>

</body>
</html>

⌨️ 快捷键说明

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