balaji_budhu
Posts: 1
|
Posted: 10/10/2007, 12:07 AM |
|
Hi All
How to upload a file from html page to database using jsp programming.
i have created a table called task_table with a field (up BLOB) as BLOB data type.
***source.html***
<input type="file" name="attach">
***up.jsp***
<%
java.io.File f=new java.io.File("attach");
java.io.FileInputStream fis= new java.io.FileInputStream(f);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:balaji","admin","qsg");
PreparedStatement pst=con.prepareStatement("insert into task_table values(?)");
pst.setBinaryStream(1,fis,(int)f.length());
pst.executeUpdate();
pst.close();
con.close();
%>
I am not able to upload a file to sql database.
I am not sure this approach is correct or not..
Please help me any one to come out of this problem...its very urgent for me
Thank you,
Balaji
_________________
Thanks&Regards,
Balaji |
|
|
|