Image name,image path into database and image into folder using jsp

Image name,image path into database and image into folder using jsp

How to insert image path and image name into oracle database and image into folder using jsp?

View Answers

November 5, 2012 at 12:37 PM

Here is a code that insert image path and name into mysql database and image into folder.

1)form.jsp:

<%@ page language="java" %>
<HTML>
<FORM ENCTYPE="multipart/form-data" ACTION="uploadFile.jsp" METHOD=POST>
<center>
<table border="0" bgcolor=#ccFDDEE>
<tr>
<center><td colspan="2" align="center"><B>UPLOAD THE FILE</B><center></td>
</tr>
<tr><td colspan="2" align="center"> </td></tr>
<tr><td><b>Choose the file To Upload:</b></td>
<td><INPUT NAME="file" TYPE="file"></td>
</tr>
<tr><td colspan="2" align="center"> </td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="Send File"> </td></tr>
<table>
</center>
</FORM>
</HTML>

2)uploadFile.jsp:

<%@ page import="java.io.*,java.sql.*" %>
<%
String saveFile="";
String contentType = request.getContentType();
if((contentType != null)&&(contentType.indexOf("multipart/form-data") >= 0)){
DataInputStream in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while(totalBytesRead < formDataLength){
byteRead = in.read(dataBytes, totalBytesRead,formDataLength);
totalBytesRead += byteRead;
}
String file = new String(dataBytes);
saveFile = file.substring(file.indexOf("filename=\"") + 10);
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1,saveFile.indexOf("\""));
int lastIndex = contentType.lastIndexOf("=");
String boundary = contentType.substring(lastIndex + 1,contentType.length());
int pos;
pos = file.indexOf("filename=\"");
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
pos = file.indexOf("\n", pos) + 1;
int boundaryLocation = file.indexOf(boundary, pos) - 4;
int startPos = ((file.substring(0, pos)).getBytes()).length;
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
File ff = new File("C:/UploadedFiles/"+saveFile);
FileOutputStream fileOut = new FileOutputStream(ff);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
%><br><table border="2"><tr><td><b>You have successfully upload the file:</b>
<%out.println(saveFile);%></td></tr></table>
<%
Connection connection = null;
String connectionURL = "jdbc:mysql://localhost:3306/roseindia";
PreparedStatement psmnt = null;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "root");
psmnt = connection.prepareStatement("insert into file(file_name,file_path) values(?,?)");
psmnt.setString(1, ff.getName());
psmnt.setString(2, ff.getPath());
int s = psmnt.executeUpdate();
if(s>0){
System.out.println("Uploaded successfully !");
}
else{
System.out.println("Error!");
}
}
catch(Exception e){
    e.printStackTrace();
}

}
%>









Related Tutorials/Questions & Answers:
Image name,image path into database and image into folder using jsp
Image name,image path into database and image into folder using jsp  How to insert image path and image name into oracle database and image into folder using jsp
how to store image in folder and stored image path in mysql database using JSP
how to store image in folder and stored image path in mysql database using JSP  how to store image in folder and stored image path in mysql database using JSP
Advertisements
How to store user name,city,state,image path into database and image into folder using jsp
How to store user name,city,state,image path into database and image into folder using jsp  How to store user name,city,state,image path into database and image into folder using jsp
i want to save image on server folder. and i want to save URL of this folder and name of image in database
and name of image in database  hi i want to save image on server folder. and i want to save URL of this folder and name of image in database.on click... name stored in database. how can i do this please suggest me.. I am using
how to display or retrive an image in jsp whose path is stored in oracle database
how to display or retrive an image in jsp whose path is stored in oracle database  how to display or retrive an image in jsp whose path is stored in oracle database and the image is stored in my pictures folder
Full path of image to save it in a folder
Full path of image to save it in a folder  Sir ,I am trying to upload a file but only sends file name as parameter. I want a code that would help me to find that image path &upload it as well. I am just a beginner in jsp
change the name of the image after uploading the image
change the name of the image after uploading the image   my form consists of a textbox and uploading the image.after uploading the image i want to change the name of the image with the content of the textbox before saving
Image upload in mysql database using jsp servlet
Image 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
How to copy an jpeg image from one folder to other folder using jsp
How to copy an jpeg image from one folder to other folder using jsp  How to copy an image from one folder to another folder using jsp
How to copy an jpeg image from one folder to other folder using jsp
How to copy an jpeg image from one folder to other folder using jsp  ... be in my image folder...so,How to copy an jpeg image from one folder to other folder using jsp or servlet
how to insert the physical path of an image in database - JDBC
how to insert the physical path of an image in database  hello I m working in a project where we have to capture an image using web cam. when the image is captured it is saved in folder in a project folder and at the same time
<img src=""> using retrieve image from database using jsp
using retrieve image from database using jsp  how to <img src="" > tag using retrieve image from database and display in jsp
retrive image from database using jsp without stream
retrive image from database using jsp without stream  How to retrive image from database using jsp without stream like (inputStream
How to store multiple images in folder and images path in database at a time using jsp?
How to store multiple images in folder and images path in database at a time using jsp?  I wanna browse multiple images in one form and store them in one folder and their path into datrabase
insert name city and upload image in database using mysql and jsp
insert name city and upload image in database using mysql and jsp   insert name city and upload image in database using mysql and jsp
How to retrieve image from database using jsp and servlet?
How to retrieve image from database using jsp and servlet?  Hi, I am trying to find code for displaying the image from database in a JSP page. How to retrieve image from database using jsp and servlet
inserting an path of an image in database - JDBC
to save it in folder..but can you plz tell me how an the full path of image can... infolder with unique name and in database its whole path get inserted code...inserting an path of an image in database  hello kindly help related
How to display image in jsp from database using Servlet?
How to display image in jsp from database using Servlet?  Hi, How to display image in jsp from database using Servlet? Thanks   Hi, You will find code and example program at Retrieve image from database using Servlet
Displaying image using jsp and spring.
Displaying image using jsp and spring.  how to display an image stored in WEB-INF/images folder on the browser using jsp and spring
Upload Image and save in database using jsp-servlet mvc
Upload Image and save in database using jsp-servlet mvc  Here is my code.. In jsp ... <form name=frm method="post" action="Device">...;/TD> <td><input type="file" name="Image" size="20" value="">
Upload Image and save in database using jsp-servlet mvc
Upload Image and save in database using jsp-servlet mvc  Here is my code.. In jsp ... <form name=frm method="post" action="Device">...;/TD> <td><input type="file" name="Image" size="20" value=""><
retrive the employee details with image from mysql database using jsp servlet
retrive the employee details with image from mysql database using jsp servlet  im doing the web project to retrive the employee profile which i stored in the database using jsp servlet then want to show the result in the next jsp
how to upload multiple files in jsp and saving the path in database and the file in folder
how to upload multiple files in jsp and saving the path in database and the file in folder  how to upload multiple files in jsp and saving the path in database and the file in folder I have created a form for the upload of files
Retrieve image from database using servlet and display in JSP
Retrieve image from database using servlet and display in JSP  Hi, I am total new to JSP although I am learning it for the last few days. Now I want to use MySQL Database from JSP page. How to retrieve image from database using
insert name city image in database using mysql and jsp
insert name city image in database using mysql and jsp  how to insert name ,city and image in database in mysql and jsp   Here is an example in jsp that insert name, city and image to database. <%@ page import
display image using jsp
display image using jsp  display image using jsp and phonegap on emulator of eclipse   Here is a simple jsp code that displays an image on browser. <%@ page import="java.io.*" %> <%@page contentType="image/gif
upload image using JSP Hibernate
upload image using JSP Hibernate  sir, I want to take image from user and save to database(MYSQL) using Hibernate and JSP Thanks in advance
Delete image from folder - JSP-Servlet
Delete image from folder  Hi Thanks Rajnikant to given me reply i am not storing my image in db just userid comming from db means my image name like : Pie(userid).png which alocated in my server folder when
Delete image from folder - JSP-Servlet
. that image name based on user id and that image is going to on folder in server after...Delete image from folder  Dear All, i used some coding... creating a new png image. in my project if two user will be login same time meanse
how to upload an image from a jsp page to a mysql database table using jsp
how to upload an image from a jsp page to a mysql database table using jsp  how to upload an image from a jsp page to a mysql database table using jspstrong text
image save to folder in java
folder and that path stored into database, for furhter retrivation. Please guide me...image save to folder in java  Hi, I am working with java. In my application i want to give facility to user to add and change image. I use open
download image using url in jsp
download image using url in jsp  how to download image using url in jsp
Uploading image using jsp
Uploading image using jsp  how to upload image using jsp. Already i... that image file ... I want know that solution using by u... Thanks, P.S.N.   Here is a jsp code that upload image and display it on the browser. 1
how to show image as a link which path coming from database
how to show image as a link which path coming from database   iam not getting proper answer for it. I am using netbeans .the url coming instring from database ,want to display as image on jsp . please help me
How to store and retrieve image from database in JSP?
How to store and retrieve image from database in JSP?  Hi, In one... and retrieve image from database in JSP? Thanks   HI, You can use... the image. Check this example: Retrieve image from database using Servlet. Thanks
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
how to store image upload path to mssql database
how to store image upload path to mssql database  hi there!!, i need help in storing the image upload path into the database. basically i just use file select to upload the image from jsp to database. however when i click submit
How to retrieve image from mysql database in JSP?
How to retrieve image from mysql database in JSP?  Hi, I need JSP... to retrieve image from mysql database in JSP? Thanks   Hi, You can write SQL query to find the data from database and get the image from resultset using
Save profile and image to mysql database, and view the image in another jsp page
Save profile and image to mysql database, and view the image in another jsp page  Pls. need help in saving the profile info with the image in mysql database.. some basic code pls in jsp... thanks in advance
How to retrieve blob image from database in JSP?
How to retrieve blob image from database in JSP?  Hello, JSP is used... the blog image from database. How to retrieve blob image from database in JSP?   Hi, Please check the tutorial Retrieve image from database using
image upload&download using jsp - JSP-Servlet
image 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
Fetching image from database
name in database so, now how can i display that image using JSP or HTML page(is it possible to display using tag using concatination). image path i have stored in database is:E:\1003\54175\20110407121554 image name i have stored
image is display from path of mysql database
image is display from path of mysql database  <%@ page import="java.io.,java.sql.,java.util.zip.*" %> <% String saveFile=""; String..._path) values(?)"); psmnt.setString(1, ff.getPath()); int s = psmnt.executeUpdate
i am inserting an image into database but it is showing relative path not absolute path
i am inserting an image into database but it is showing relative path not absolute path   hi my first page......... Image Enter your name: Upload photo: Father name: Age: Username: Password Qualification: Gender: Phone
i am inserting an image into database but it is showing relative path not absolute path
i am inserting an image into database but it is showing relative path not absolute path   hi my first page......... Image Enter your name: Upload photo: Father name: Age: Username: Password Qualification: Gender: Phone
image in database
image in database  how to set image in database and retrieve it using servlet(java)in msaccess
image in jsp - JSP-Servlet
image 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
how to fetch image from mysql using jsp
how to fetch image from mysql using jsp  how to fetch image from mysql using jsp

Ads