Topic: 怎样用jsp上传文件 |
Print this page |
1.怎样用jsp上传文件 | Copy to clipboard |
Posted by: kylin Posted on: 2003-08-07 16:04 我用tomcat,jsp等作一个电子相册,如有注册用户上传其相片,怎样实现他的上传,用代码怎样实现,在此先谢过各位大虾了 |
2.Re:怎样用jsp上传文件 [Re: kylin] | Copy to clipboard |
Posted by: floater Posted on: 2003-08-07 23:51 search here or google for 3rd party ftp java tool libs. |
3.Re:怎样用jsp上传文件 [Re: kylin] | Copy to clipboard |
Posted by: jigsaw Posted on: 2003-08-08 16:18 google: SmartUpload + jsp |
4.Re:怎样用jsp上传文件 [Re: kylin] | Copy to clipboard |
Posted by: linux_china Posted on: 2003-08-09 20:42 please see http://www.cjsdn.com/post/view?bid=21&id=44478&sty=1&tpg=1&age=0 |
5.Re:怎样用jsp上传文件 [Re: kylin] | Copy to clipboard |
Posted by: yekai Posted on: 2003-08-11 00:45 用jspSmart的jspSmartUpload,我用过,很好用: http://www.jspsmart.com/ |
6.Re:怎样用jsp上传文件 [Re: kylin] | Copy to clipboard |
Posted by: leo_wu Posted on: 2003-08-11 11:11 确实很好用,只要自己写一点代码就可以啦。 |
7.Re:怎样用jsp上传文件 [Re: kylin] | Copy to clipboard |
Posted by: fjzuser Posted on: 2003-08-13 14:40 给你个我上传的用jspsmart的程序 <%@ page import="java.sql.*" %> <%@page contentType="text/html;charset=gb2312" language="java" import="com.jspsmart.upload.*"%> <jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" /> <HTML> <BODY > <H1>文件上传JSP</H1> <HR> <% int count=0; //定义目标目录 mySmartUpload.initialize(pageContext); //文件上传 mySmartUpload.upload(); //获得文本的内容 String date1= mySmartUpload.getRequest().getParameter("date"); out.println(date1+"<br>"); String type1 = mySmartUpload.getRequest().getParameter("type"); out.println(type1+"<br>"); String path1 = mySmartUpload.getRequest().getParameter("path"); out.println(path1+"<br>"); String title1 = mySmartUpload.getRequest().getParameter("title"); out.println(title1+"<br>"); String class1 = mySmartUpload.getRequest().getParameter("class"); out.println(class1+"<br>"); String attrib1 = mySmartUpload.getRequest().getParameter("attrib"); out.println(attrib1+"<br>"); String dest1="/td/"; dest1=dest1+type1+"/"; String filename1=""; //上传的情况统计 //for (int i=0;i<mySmartUpload.getFiles().getCount();i++){ com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0); if (!myFile.isMissing()){ myFile.saveAs(dest1+ myFile.getFileName()); filename1=myFile.getFileName(); out.println("文件名称= " + myFile.getFieldName() + "<BR>"); out.println("文件大小= " + myFile.getSize() + "<BR>"); out.println("文件名称= " + myFile.getFileName() + "<BR>"); out.println("文件大小= " + myFile.getFileExt() + "<BR>"); out.println("文件路径名= " + myFile.getFilePathName() + "<BR>"); out.println("文件类型= " + myFile.getContentType() + "<BR>"); out.println("ContentDisp = " + myFile.getContentDisp() + "<BR>"); out.println("MIME类型 = " + myFile.getTypeMIME() + "<BR>"); out.println("SubTypeMIME = " + myFile.getSubTypeMIME() + "<BR>"); out.println(filename1); //count ++; //} } //out.println("<BR>可以上传" + mySmartUpload.getFiles().getCount() + "个文件<BR>"); //out.println(count + "个文件已经被上传"); //插入数据库记录 try { Class.forName("com.mysql.jdbc.Driver").newInstance(); } catch (java.lang.ClassNotFoundException e) { out.print("Class not found exception occur. Message is:"); out.print(e.getMessage()); } try { Connection con; Statement stmt; con = DriverManager.getConnection("jdbc:mysql://localhost:3306/webuser?useUnicode=true&characterEncoding=gb2312","webuser","webuser"); stmt = con.createStatement(); stmt.executeUpdate("insert into document(date,type,title) Values('"+date1+"','"+type1+"','"+filename1+"')"); } catch (SQLException e) { out.print("<br>SQL Exception occur. Message is:"); out.print(e.getMessage()); } %> <p><a href="view.jsp">返回</a></p> </BODY> </HTML> |
8.Re:怎样用jsp上传文件 [Re: kylin] | Copy to clipboard |
Posted by: kylin Posted on: 2003-08-20 10:38 已经解决了此问题,非常感谢大家的帮助,以后有什么不懂的地方还要靠大家的帮助 |
9.Re:怎样用jsp上传文件 [Re: kylin] | Copy to clipboard |
Posted by: kerik Posted on: 2003-09-30 17:58 上传文件的组件 这里有: http://www.croview.org |
10.Re:怎样用jsp上传文件 [Re: kylin] | Copy to clipboard |
Posted by: hitaco Posted on: 2003-10-01 12:05 1. use 3-party component 2. write ur own |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |