根据网上的一个上传范例做的,可是怎么也不传,大家帮我看看吧
运行后不提示出错,但并没有文件上传到数据库,帮我看看是怎么回事吧
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="com.oreilly.servlet.MultipartRequest" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%
String dllname = request.getParameter("dllname");
String info=request.getParameter("info");
if (dllname==null) dllname="";
if (info==null) info="";
String opertid=request.getParameter("opertid");
String opername="驱动管理";
if (opertid==null) opertid="none";
if (opertid!="none"){
if (opertid.equals("add")){
String s = null;
byte temp [];
String Name = "";
String s1 = request.getHeader("Content-Type");
String s2 = request.getContentType();
if (s1 == null && s2 != null)
s = s2;
else if(s2 == null && s1 != null)
s = s1;
else if(s1 != null && s2 != null)
s = (s1.length() <= s2.length())? s2:s1;
if( s != null && s.toLowerCase().startsWith("multipart/form-data"))
{
String dir=".\\";
// 上传档案大小限制
int size=100*1024*1024;
MultipartRequest mr=new MultipartRequest(request,dir,size);
String fileName = "";
Enumeration filesname = mr.getFileNames();
while (filesname.hasMoreElements())
{
String name = (String) filesname.nextElement();
fileName = mr.getFilesystemName(name);
temp=fileName.getBytes("iso-8859-1");
Name = new String(temp);
}
java.io.File file=null;
file = new java.io.File(fileName);
java.io.InputStream inStream = new java.io.FileInputStream(file);
long filesize=file.length();
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.129:1521:qq","qq", "qq");
String strSql = "insert into QQ_DRIVER values('" + Name + "'," + filesize +", '"+ info +"',sysdate,?)";
PreparedStatement stmt = conn.prepareStatement(strSql);
stmt.setBinaryStream(1,inStream,size);
int i= stmt.executeUpdate();
inStream.close();
stmt.close();
}
}
}
%>
<body bgcolor="#CCCCCC" onMouseMove="javaScript:OffNum=0">
<div id="bkdiv" >
<form name='frmDriver' action='driver.jsp' method='post' enctype='multipart/form-data'>
<table height="100%" width="100%" border=0 cellpadding="0" cellspacing="1">
<%@ include file="phstop.jsp"%>
<tr>
<td width="100%" height="1" align=Left><font color=#000000 size="2" face="宋体"></font><td>
</tr>
<tr>
<td valign="top" width="100%" height="97%" bgcolor="#FFFFFF" >
<table BGCOLOR="#EFEFEF" width="100%" border=0 cellpadding="0" cellspacing="0">
<tr>
<td ><font color=blue size="2" face="宋体">
文件名:<input type='file' name='filename' size='25'>
说明:<input name="info" value=''>
<input name="btnAdd" type="button" onClick="onAdd()" VALUE="添加">
</font>
</td>
</tr>
<tr bgcolor="#C7D7F3" >
<td height="20"><font size="2" face="宋体">总数:<Strong><%=vlst.size()-1%></Strong></font>
</td>
</tr>
</table>
<td>
</tr>
</table>
<input type="hidden" name="dllname" value=<%=dllname%>>
<input type="hidden" name="opertid" value=<%=opertid%>>
<input type="hidden" name="clickstr" value="">
<input type="hidden" name="valuestr" value="">
</form>
</div>
<%PrintBarInfo(out);%>
<script language="JavaScript">
with(document.all.bkdiv.style){
left=(screen.width-800)/2;
}
</script>
</body>
</html>
<Script language="javascript">
function onAdd(){
frmDriver.opertid.value="add";
frmDriver.submit();
}
</Script>
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="com.oreilly.servlet.MultipartRequest" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%
String dllname = request.getParameter("dllname");
String info=request.getParameter("info");
if (dllname==null) dllname="";
if (info==null) info="";
String opertid=request.getParameter("opertid");
String opername="驱动管理";
if (opertid==null) opertid="none";
if (opertid!="none"){
if (opertid.equals("add")){
String s = null;
byte temp [];
String Name = "";
String s1 = request.getHeader("Content-Type");
String s2 = request.getContentType();
if (s1 == null && s2 != null)
s = s2;
else if(s2 == null && s1 != null)
s = s1;
else if(s1 != null && s2 != null)
s = (s1.length() <= s2.length())? s2:s1;
if( s != null && s.toLowerCase().startsWith("multipart/form-data"))
{
String dir=".\\";
// 上传档案大小限制
int size=100*1024*1024;
MultipartRequest mr=new MultipartRequest(request,dir,size);
String fileName = "";
Enumeration filesname = mr.getFileNames();
while (filesname.hasMoreElements())
{
String name = (String) filesname.nextElement();
fileName = mr.getFilesystemName(name);
temp=fileName.getBytes("iso-8859-1");
Name = new String(temp);
}
java.io.File file=null;
file = new java.io.File(fileName);
java.io.InputStream inStream = new java.io.FileInputStream(file);
long filesize=file.length();
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.129:1521:qq","qq", "qq");
String strSql = "insert into QQ_DRIVER values('" + Name + "'," + filesize +", '"+ info +"',sysdate,?)";
PreparedStatement stmt = conn.prepareStatement(strSql);
stmt.setBinaryStream(1,inStream,size);
int i= stmt.executeUpdate();
inStream.close();
stmt.close();
}
}
}
%>
<body bgcolor="#CCCCCC" onMouseMove="javaScript:OffNum=0">
<div id="bkdiv" >
<form name='frmDriver' action='driver.jsp' method='post' enctype='multipart/form-data'>
<table height="100%" width="100%" border=0 cellpadding="0" cellspacing="1">
<%@ include file="phstop.jsp"%>
<tr>
<td width="100%" height="1" align=Left><font color=#000000 size="2" face="宋体"></font><td>
</tr>
<tr>
<td valign="top" width="100%" height="97%" bgcolor="#FFFFFF" >
<table BGCOLOR="#EFEFEF" width="100%" border=0 cellpadding="0" cellspacing="0">
<tr>
<td ><font color=blue size="2" face="宋体">
文件名:<input type='file' name='filename' size='25'>
说明:<input name="info" value=''>
<input name="btnAdd" type="button" onClick="onAdd()" VALUE="添加">
</font>
</td>
</tr>
<tr bgcolor="#C7D7F3" >
<td height="20"><font size="2" face="宋体">总数:<Strong><%=vlst.size()-1%></Strong></font>
</td>
</tr>
</table>
<td>
</tr>
</table>
<input type="hidden" name="dllname" value=<%=dllname%>>
<input type="hidden" name="opertid" value=<%=opertid%>>
<input type="hidden" name="clickstr" value="">
<input type="hidden" name="valuestr" value="">
</form>
</div>
<%PrintBarInfo(out);%>
<script language="JavaScript">
with(document.all.bkdiv.style){
left=(screen.width-800)/2;
}
</script>
</body>
</html>
<Script language="javascript">
function onAdd(){
frmDriver.opertid.value="add";
frmDriver.submit();
}
</Script>
...全文
相关推荐
springboot+vue 大文件上传 包括断点续传 秒传 分片上传.zip
适合快速集成vue 大文件上传的项目 包括断点续传 秒传 分片上传
web大文件上传、秒传、分块上传演示c#.net
使用webupload实现了在C# .net项目中的断点续传演示(绝对不亏的,现在.net中webupload服务端好多都不完整,我这个是自己写完用到项目中的,比较稳定,虽然代码比较初级,后面也没整理) 演示地址:http://zq.cdivtc.com/mingapp 主要功能: 1、支持断点续传 2、支持分块上传 3、支持多线程 4、支持文件秒传 5、支持显示上传进度 6、支持图片预览 7、支持暂停上传 8、拖拽上传 文件列表: (1)index.html是演示上传的 (2)server/webup.aspx是后台接收上传的(另外两ashx是测试文件) (3)webuploader.js和upload.js是webupload的配置文件和JS分片支持文件 (4)scripts及styles文件夹是JS和CSS等文件 (5)upload文件夹是默认的上传文件夹
网上传文系统.rar_传文件
网上传文系统,可以实现通过网络发布文件,用户可以通过密码接受相应的文件,绝对好用!
springboot整合plupload,实现文件批量上传、断点续传、秒传 源码
springboot2、plupload2.3.6整合,实现文件批量上传、断点续传、秒传,带进度条,idea、maven工程
SpringBoot 中大文件(分片上传)断点续传与极速秒传功能的实现
主要介绍了SpringBoot 中大文件(分片上传)断点续传与极速秒传功能的实现,需要的朋友可以参考下


Web 开发
