📄 upload.jsp
字号:
<%@ page language="java" import="java.util.*,java.sql.*,java.io.*" pageEncoding="GBK" errorPage="Upload.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%if((String) session.getAttribute("login") == null) {
response.sendRedirect("Login.jsp");
}
String dir=(String)session.getAttribute("dir");
String type=(String)session.getAttribute("type");
if(dir == null || type == null)
response.sendRedirect("SelectDir.jsp");
%>
<%@ page contentType="text/html;charset=gb2312" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>dream photo album upload picture</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body style="BACKGROUND: #000000" onload="init()">
<SCRIPT language="JavaScript">
<!--
function make(){
document.UploadPicture.dir.value=document.UploadPicture.listdir.value;
document.UploadPicture.type.value=document.UploadPicture.listtype.value;
}
function changedir()
{
document.UploadPicture.dir.value=document.UploadPicture.listdir.value;
}
function changetype()
{
document.UploadPicture.type.value=document.UploadPicture.listtype.value;
}
function init()
{
document.UploadPicture.dir.value=document.UploadPicture.listdir.value;
document.UploadPicture.type.value=document.UploadPicture.listtype.value;
}
// -->
</SCRIPT>
<P>
<BR>
</P>
<CENTER>
<FONT color="#0000ff" size="5">Welcome to my dream photo album</FONT>
</CENTER>
<P></P><P>
<BR>
<FONT color="#ff0080">Welcome,<%=session.getAttribute("id")%></FONT> </P>
</P> <FONT color="#ff0080">
<A href='UserModify.jsp?id=<%=session.getAttribute("id")%>'>
<FONT color="#23ded5">Modify infomation </FONT></A>
<FONT color="#23ded5"> </FONT></FONT>
<A href="MyManager.jsp">
<FONT color="#23ded5"> Picture Manager</FONT></A><FONT color="#23ded5">
<FONT></FONT><A href="Upload.jsp"><FONT color="#23ded5"> Upload picture</FONT></A>
<FONT color="#23ded5">
</FONT><A href="Login.jsp"><FONT color="#23ded5">Login</FONT></A>
</P>
<FORM name="UploadPicture" enctype="multipart/form-data" action="servlet/UploadPictureServlet" method="post">
<BR>
<BR>
<BR>
<BR>
<br>
<br>
<center><FONT color="#00ff00">Please choose the direction:</FONT>
<select name="listdir" onchange="changedir()">
<%
try {
String myid=(String)(session.getAttribute("id"));
int total = 0;
Class.forName("com.mysql.jdbc.Driver");
Connection c = DriverManager
.getConnection("jdbc:mysql://localhost/myphone?user=root&password=123456"); // 连接mysql数据库
Statement s = c.createStatement();
String sql="select DirName from userdir where ID='"+myid+"'";
//System.out.println(sql);
ResultSet r = s.executeQuery(sql);
int k = 1;
while(r.next())
{
%>
<OPTION value="<%=r.getString(1) %>"><%=r.getString(1) %></OPTION>
<%
k++;
total++;
}
s.close();
} catch (Exception e) {
e.printStackTrace();
}
%>
</select>
<FONT color="#00ff00">Please choose the type:</FONT>
<select name="listtype" onchange="changetype()">
<%
try {
String myid=(String)(session.getAttribute("id"));
int total = 0;
Class.forName("com.mysql.jdbc.Driver");
Connection c = DriverManager
.getConnection("jdbc:mysql://localhost/myphone?user=root&password=123456"); // 连接mysql数据库
Statement s = c.createStatement();
String sql="select type from usertype where ID='"+myid+"'";
//System.out.println(sql);
ResultSet r = s.executeQuery(sql);
int k = 1;
while(r.next())
{
%>
<OPTION value="<%=r.getString(1) %>" ><%=r.getString(1) %></OPTION>
<%
k++;
total++;
}
s.close();
} catch (Exception e) {
e.printStackTrace();
}
%>
</select>
</center>
<br>
<center>
<FONT color="#00ff00">your direction is</FONT>
<INPUT type="text" name="dir">
<FONT color="#00ff00">your type is</FONT>
<INPUT type="text" name="type" />
<br>
<br>
</center>
<center>
<FONT color="#00ff00">please choose the file you want to upload</FONT>
<INPUT type="file" name="file">
</center>
<center>
<INPUT type="submit" name="button1" value="upload...">
<INPUT type="reset" name="button2" value="reset">
<P></P>
</center>
</FORM>
<br>
<FONT color="#ff0080">
<br>
<br>
<center> please make sure the upload picture with prefix jpg,gif but not upper</center></FONT>
<BR> <BR><BR> <BR>
<a href="SelectDir.jsp"><FONT color="#00ff00">choone the upload dir against</FONT></a>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -