package servlet;
import java.io.*;
import java.io.File;
import java.sql.*;
import java.util.*;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jspsmart.upload.*;
import DB.conndb;
public class upload1 extends HttpServlet {
/**
* Constructor of the object.
*/
public upload1() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=gb2312");
response.setCharacterEncoding("gbk");
PrintWriter out=response.getWriter();
SmartUpload su =new SmartUpload();
su.initialize(this.getServletConfig(), request, response);
su.setAllowedFilesList("gif,jpg,png,bmp,jpeg,JPEG,BMP,GIF,JPG,PNG");
String realPath = this.getServletContext().getRealPath("");
String path=realPath+"\\photo\\"+request.getSession().getAttribute("username");
// String fileName=path+su.getFiles().getFile(0).getFileName();
System.out.println(""+realPath);
System.out.println(""+path);
File f=new File(path);
if(!f.exists()){f.mkdirs();}
/* File checkFile = new File(fileName);
if(checkFile.exists()){
out.println("<p>文件已经存在.</p>");
response.sendRedirect("upload.jsp");
}*/
try {
su.upload();
int count=su.save(path);
System.out.println(""+count);
com.jspsmart.upload.File file=su.getFiles().getFile(0);
System.out.println(""+file.getFileName());
Date date=new Date();
String s=""+date.getYear()+date.getMonth()+date.getDay()+date.getHours()+date.getHours()+date.getMinutes()+date.getSeconds()+file.getFileName();
System.out.println(s);
file.saveAs(path+"\\\\"+s);
String username=request.getSession().getAttribute("username").toString();
String note=su.getRequest().getParameter("note");//注意这是接收表单传过来的参数
String authority=su.getRequest().getParameter("Item1");
String album=su.getRequest().getParameter("Item2");
System.out.println(username);
System.out.println(note);
System.out.println(authority);
System.out.println(album);
String sql="insert into photo(user_id,note,path,authority,album_name) values('"+username+"','"+note+"','"+username+"/"+s+"','"+authority+"','"+album+"')";
String sql1="select * from photo where album_name='"+album+"'";
System.out.println(sql1);
String sql2="update album set fengmian='"+"/photo/"+username+"/"+s+"' where album_name='"+album+"'";
System.out.println(sql2);
conndb con =new conndb();
ResultSet rs=null;
rs=con.executeQuery(sql1);
if(!rs.next()){
con.executeUpdate(sql2);
};
con.executeUpdate(sql);
String path1=path+"\\"+file.getFileName();
File f1=new File(path1);
if(f1.isFile()&&f1.exists()){f1.delete();}
out.print("<script language='javascript'>alert('照片上传成功!');window.location.href='myalbum';</script>");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
java web个人相册系统
共212个文件
class:34个
java:34个
jsp:19个
1星 需积分: 50 102 下载量 65 浏览量
2018-05-07
23:57:51
上传
评论 16
收藏 11.69MB ZIP 举报
温馨提示
语言java web,数据库mysql,压缩包包含数据库、文档、源码、演讲ppt、还有写写文档的画图(viso),其中文档包含:源码说明、解决分案、需求分析、详细设计、概要设计、软件测试报告,软件开发的各个阶段几乎涵盖。
资源推荐
资源详情
资源评论
收起资源包目录
java web个人相册系统 (212个子文件)
blogPhotoAd 24B
upload1.class 5KB
myinfo1.class 4KB
delete.class 4KB
myphoto.class 4KB
friendphoto.class 4KB
friendalbum.class 4KB
mycomment.class 3KB
albumDao.class 3KB
myalbum.class 3KB
addfd.class 3KB
myfriend.class 3KB
mynews.class 3KB
friendcomment.class 3KB
creatalbum.class 3KB
Zhuce.class 3KB
upload.class 3KB
jieshouask.class 3KB
conndb.class 3KB
xiugai.class 3KB
newsDao.class 2KB
commentDao.class 2KB
photoDao.class 2KB
addcomment.class 2KB
LoginDeal.class 2KB
friendDao.class 2KB
myinfo.class 2KB
myinfoDao.class 2KB
SetCharacterEncodingFilter.class 2KB
myinfo1.class 1KB
album.class 1KB
photo.class 1KB
news.class 1KB
comment.class 1KB
friend.class 762B
.classpath 529B
org.eclipse.wst.common.component 455B
org.eclipse.wst.jsdt.ui.superType.container 49B
global_base_780b8ff.css 185KB
styleV1.3.css 112KB
global.css 20KB
square.css 9KB
base.css 7KB
使用说明.doc 4.93MB
软件测试报告.doc 1.06MB
概要设计.doc 1019KB
详细设计.doc 488KB
需求分析.doc 240KB
源代码说明.doc 41KB
解决方案.docx 143KB
WhiteLoading.gif 11KB
none160.gif 11KB
sh.gif 1KB
CustomBlackNext.gif 1KB
CustomBlackPrevious.gif 1KB
sina_icon.gif 1KB
sh_icon.gif 1KB
sj.gif 784B
hx.gif 744B
sina.gif 604B
qq.gif 545B
qq_kj.gif 544B
rr.gif 535B
CustomBlackClose.gif 518B
db.gif 432B
qq_icon.gif 271B
hx_logo.gif 238B
gd_zf.gif 181B
mysql-connector-java-5.1.7-bin.jar 693KB
commons-beanutils.jar 184KB
commons-io-1.4.jar 106KB
commons-fileupload-1.2.1.jar 56KB
jspsmartupload.jar 12KB
upload1.java 4KB
delete.java 4KB
myphoto.java 4KB
myinfo1.java 4KB
friendphoto.java 3KB
friendalbum.java 3KB
mycomment.java 3KB
addfd.java 3KB
albumDao.java 3KB
Zhuce.java 3KB
friendcomment.java 3KB
myalbum.java 3KB
myfriend.java 3KB
mynews.java 3KB
creatalbum.java 3KB
newsDao.java 3KB
photoDao.java 3KB
jieshouask.java 3KB
friendDao.java 3KB
xiugai.java 3KB
addcomment.java 2KB
upload.java 2KB
LoginDeal.java 2KB
commentDao.java 2KB
myinfo.java 2KB
myinfoDao.java 2KB
conndb.java 2KB
共 212 条
- 1
- 2
- 3
资源评论
- 123@1232019-07-01数据库文件都没有
梦寐芊荨
- 粉丝: 29
- 资源: 24
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- KIMI大模型浏览器插件
- b61fa64a08a02de0e0d49d53bb84c444.amr
- 5ffd9193f6aec31bbf16030a46680dc7.avi
- DA14531-蓝牙传感器连接传输数据固件
- logisim实验MIPS运算器(ALU)设计(内含4位先行进位74182、四位快速加法器、32位快速加法器)-Educoder_logisim里面连线,实现4位先行进位74182和4位快速加法器-C
- 高等数学第一章第二节数列的极限
- Python 版冒泡排序算法源代码
- 基于YOLOv8的教室人脸识别 附源码 预训练模型
- 基于JAVA实现的用于全局监控网络请求错误并记录日志的library
- tensorflow-gpu-2.7.2-cp38-cp38-manylinux2010-x86-64.whl
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功