Upload Image and save in database using jsp-servlet mvc
Here is my code..
In jsp ...
<form name=frm method="post" action="Device">
<table>
<tr><TD ><B>Upload Image</B></TD>
<td><input type="file" name="Image" size="20" value=""></TD>
</tr>
<tr>
<td><input type="submit" height="30" width="62"> </td>
</tr>
</form>
<form name=frm method="post" action="Device">
<table>
<tr><TD ><B>Upload Image</B></TD>
<td><input type="file" name="Image" size="20" value=""></TD>
</tr>
<tr>
<td><input type="submit" height="30" width="62"> </td>
</tr>
In servlet...
try
{
String strpath=request.getParameter("Image");
String filepath=strpath.substring(strpath.lastIndexOf("\\")+1);
File imgfile = new File(strpath);
FileInputStream fin = new FileInputStream(imgfile);
Connection connection=null;
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
PreparedStatement pre = connection.prepareStatement("insert into uploadimage(image,image_name,image_length) values(?,?,?)");
pre.setBinaryStream(1,fin,(int)imgfile.length());
pre.setString(2,filepath);
pre.setLong(3,imgfile.length());
pre.executeUpdate();
pre.close();
String L_url1=response.encodeRedirectURL("Device.jsp");
response.sendRedirect(L_url1);
}
catch(Exception ex){
System.out.println("Exception in InsertImage : "+ex.getMessage());
}
}
but throws exception
(The system cannot find the file specified)
How to rectify.
View Answers
Related Tutorials/Questions & Answers:
Advertisements
Image upload in mysql database using jsp servletImage upload in mysql
database using jsp servlet Hello, I need code to insert
image in mysql
database, I have seen the code which is already in your portal but it is not inserting
image into
database it
save in the folder
Upload Image to Database through Servlet - JSP-ServletUpload Image to
Database through Servlet Hello,
I make a application from where I
upload the
Image from local disk then store in DB.Before storing...:101249][ServletContext(id=29091418,name=
Upload,context-path=/
Upload)]:
Servlet class
Image upload file - JSP-ServletImage upload file I want a code for
image upload jsp or
servlet. Hi friend,
For
image upload jsp or
servlet visit to :
http://www.roseindia.net/
jsp/file_
upload/employee_
upload_profile_image.shtml
http
upload to database - JSP-Servletupload to database hai friends i have a query that is i have to
upload a pdf file into
database(sqlserver2000)
using jsp. In roseindia some examples... into
database whenever
i want that uploaded pdf file i have to retrieve
how to save uploaded image in database using javascripthow to
save uploaded
image in
database using javascript Please can you tell me how to store uploaded
image in
database using java I'll use the
upload code as
extArray = new Array(".gif", ".jpg", ".png");
function LimitAttach
Insert image from user using and save in databaseInsert
image from user
using and
save in database when i am trying to
upload a
image from user and trying to
save into oracle9i
database...){e.printStackTrace();}
}
%>
3)For oracle
database, use BLOB datatype for
image Jsp using mvc - JSP-ServletJsp using mvc hi
I have written
using mvc2 architecture, i have written logic in java ,i want to print a message on the form stating the the values... closely together.
Read
MVC 2 Pattern in Struts2 in details and visit
image upload&download using jsp - JSP-Servletimage upload&download
using jsp can any one help in writing
jsp for
upload and download of images from
database.. Hi Friend,
Please visit the following links:
http://www.roseindia.net/
jsp/fileupload.shtml
http
edit database using jsp and servletedit
database using jsp and servlet I am creating a website
using jsp and servlets that is used to view houses from a
database. I want to be able... information from the
database in the textboxes. Please help me to display
retriving image from database - JSP-Servletretriving
image from database how to retrive
image from mysql
database by
using servlet programming Hi Friend,
Please visit the following link:
http://www.roseindia.net/servlets/retreiveimage.shtml
Thanks
upload image to databaseupload image to database i am try to
upload image to MySql
database using netbeans.
when
jsp execute it return no error. but also data does inserted in
database. i am
using blob datatype and preopared statement
fetch record from oracle database using jsp-servlet?fetch record from oracle
database using jsp-
servlet? how can i fetch data from oracle
database by
using jsp-
servlet. i'm
using eclipse, tomcat server and oracle
database and creating
jsp pages and also
using servlet upload image using JSP Hibernateupload image using JSP Hibernate sir,
I want to take
image from user and
save to
database(MYSQL)
using Hibernate and
JSP
Thanks in advance
Upadate Database using updatable fields - JSP-ServletUpadate
Database using updatable fields Hi,
Thanks for previous answers.They were of Great Help !!!
I want to create a
jsp in which data is pulled from
database and displayed
in the updatable fields.Means after user
upload images - JSP-Servletupload images How to write the
jsp code to
upload images... to
upload any file therefor it can also
upload an
image and can insert...://www.roseindia.net/
jsp/
upload-insert-csv.shtml
Thanks
Upload the picture - JSP-Servlet://www.roseindia.net/
jsp/file_
upload/employee_
upload_profile_image.shtml
Thanks
RoseIndia...
Upload the picture Dear Sir,
How to
upload the picture in the
database a webpage and i want to show that picture another page. what i
insert image - JSP-Servlet into oracle
database
using JSP but i am not geting so please friends send me the code for inserting
image into
database using JSP Hi Friend,
Try... = connection.prepareStatement("insert into
save_
image(name,
image) values
image in jsp - JSP-Servletimage in jsp i m storing path of
image in my
database.. but when i m trying to display
image using that path
image is not getting... i m storing path like c:\
image\a.jpg ... and i m
using tag... how to get
Multiple image upload using JSPMultiple
image upload using JSP I have written a code to
upload the multiple images
using jsp, but when I execute this code, it throws Corrupt form... = getServletContext().getRealPath("/") +
> File.separator +
>
UPLOAD_DIRECTORY;/*
save