how can upload doc file into database !!
Dear Everyone,
How can i upload a doc file into Mysql database ....
can any one please give ur suggestions...
i will show u my code
upload.jsp
**********
<form name="uploader" action="uploaded.jsp"
enctype="multipart/form-data">
<div align="center">
<table id="table1" border="1" bordercolor="#ff0000"
cellpadding="0" cellspacing="0" width="50%">
<tbody bgcolor="#c8d8f8">
<tr>
<td bgcolor="#ccccff">
<p align="center">
Resume Upload!
</td>
</tr>
<tr>
<td>
<p align="center">You can upload your
resume..
<p align="center">
<table align="center" border="1"
cellpadding="10" cellspacing="10">
<tbody>
<tr>
<td>
<input name="file" type="file">
<input name="uploadButton" value="Upload"
type="submit">
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</form>
uploaded.jsp
***********
<BODY>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%
String file1=request.getParameter("file");
int len;
String query;
PreparedStatement pstmt;
int i=0;
Class.forName("com.mysql.jdbc.Driver");
DriverManager.getConnection("jdbc:mysql://localhost:3306Connection conn= /employee","root","");
try{
File file =new File(file1);
if (file==null)
{
%>
<center>Nothing in It</center>
<%
}
else
{
FileInputStream fis =new FileInputStream(file);
len = (int)file.length();
query = ("insert into loader(resume) VALUES(?)");
pstmt = conn.prepareStatement(query);
pstmt.setString(1,file.getName());
pstmt.setInt(2, len);
//method to insert a stream of bytes
pstmt.setBinaryStream(3, fis, len);
i=pstmt.executeUpdate();
if(pstmt!=null)
pstmt.close();
if(conn!=null)
conn.close();
}
}catch (Exception e){
e.printStackTrace();
}
if(i>0)
{
out.println("uploaded");
}
else
{
out.println("not uploaded")
}
%>
</BODY>

