用IE浏览的呀?服务器上运行没任何问题,在客户端就出现找不到该文件(估计他默认就是服务器的路径):
<%
filepath = (String)request.getParameter("load");
if((filepath==null)||(filepath.length() < 1))
{
//没有选择了文件路径
//System.out.println("选择文件的路径为空");
}
else
{
//选择了文件路径
System.out.println("选择的路径: "+filepath);
//转换文件路径格式
for(int i=0;i<(int)filepath.length();i++ )
{
filepath_byte = filepath.substring(i,i+1);
if (filepath_byte.equals("//"))
{
filepath_new = filepath_new + "////";
}
else
{
filepath_new = filepath_new + filepath_byte;
if (filepath_byte.equals("."))
{
filetype=".";
}
else
{
filetype = filetype + filepath_byte;
}
}
}
System.out.println("选择的路径(转换后): "+filepath_new );
File files = new File(filepath);
filename = files.getName();
FileInputStream Fin = new FileInputStream(filepath_new);
//连接数据库
conn = tools.connectDatabase("oraclePool");
stmt = tools.getStatement(conn);
boolean defaultCommit = conn.getAutoCommit();
conn.setAutoCommit(false);
try
{
//自动生成编号
ResultSet rs1 = tools.execQuery(stmt,"SELECT to_number(max(to_number(code))+1) FROM hhf");
while (rs1.next())
{
maxcode = rs1.getString(1);
System.out.println("maxcode1: "+maxcode );
}
if((maxcode==null)||(maxcode.length() < 1))
{
maxcode = "1";
}
//插入记录
tools.execBatchUpdate(stmt,"delete from hhf where code='"+maxcode+"';INSERT INTO hhf VALUES ('"+maxcode+"',EMPTY_BLOB(),'"+filename+"','"+filetype+"',"+Fin.available()+")");
ResultSet rs = tools.execQuery(stmt,"SELECT blob FROM hhf WHERE code='"+maxcode+"' FOR UPDATE");
while (rs.next())
{
java.sql.Blob blob = rs.getBlob(1);
BufferedOutputStream out1 = new BufferedOutputStream(((oracle.sql.BLOB)blob).getBinaryOutputStream());
BufferedInputStream in = new BufferedInputStream(new FileInputStream(filepath));
int c;
while ( (c = in.read()) != -1)
{
out1.write(c);
}
in.close();
out1.close();
conn.commit();
conn.setAutoCommit(defaultCommit);
}
} catch (Exception ex)
{
conn.rollback();
throw ex;
}
}
%>