aspose file tools*
The moose likes Servlets and the fly likes How to add a passport image to a form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to add a passport image to a form" Watch "How to add a passport image to a form" New topic
Author

How to add a passport image to a form

Joe Don
Ranch Hand

Joined: Jun 01, 2012
Posts: 44
Hi friends, i have a GUI form which i have linked to database successfully. The code is java-based and i use the NetBeans 7.1 IDE. My problem is: how can users add their photo passport image to be stored in the database through the form? Thank you.
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

on the db you will need a blob column, there is loads of advice in this forum about that (so it must be quite problematic I suppose).

How to get the image from the web page to the servlet is a question for the servlets forum, so i will move you there.

The code will need to stop being netbeans based if you actually want real life users to use it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61201
    
  66

See the JspFaq for info on file uploading.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joe Don
Ranch Hand

Joined: Jun 01, 2012
Posts: 44
Thank you for your response. As a novice, i need some guide or basically, a link to a good and easy-to-understand tutorial about using BLOB. I do nt quite understand your explanation. Do assist me further, please. Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61201
    
  66

Did you read the FAQ? Do you have specific questions?

There are two steps to this: uploading the file, and then storing it in the database. I'd get the first in place before worrying about the second.
shraddha sawant
Greenhorn

Joined: Sep 06, 2011
Posts: 12

I used javazoom package for uploding files to server.
paste uploadbean.jar path in classpath environment.
I have attached that simple application, you can check.
otherwise, we have to write code, I am also working on it. if you find let me know.


shraddhasav
Ch Nageswara Reddy
Greenhorn

Joined: Jun 14, 2012
Posts: 1
Hi,

You can store the images in the database by using blob in JDBC

Follow this program,



package com.blob.clob;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class StoreImage {
public static void main(String[] args) throws SQLException, FileNotFoundException {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection con=DriverManager.getConnection("jdbcracle:thin:@localhost:1521:xe", "nagesh", "chaduvula");
PreparedStatement pstmt=con.prepareStatement("insert into blob_table values(?, ?)");
File f=new File("D:\\asim.jpg");
FileInputStream fis=new FileInputStream(f);
pstmt.setBinaryStream(1, fis, (int)f.length());
pstmt.setInt(2, 1);
System.out.println("No. of rows affected: "+pstmt.executeUpdate());
System.out.println("Image length: "+f.length());
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to add a passport image to a form