please give code..
Image upload
how to upload image in jsp using glassfish server.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ajay Patel138 reputationPosted Oct 13, 2012, 3:47 AM EDT
String exsistingFileName= "C:\\temp\\myimage.gif";
File file = new File(exsistingFileName);
FileInputStream fis = new FileInputStream(file);
PreparedStatement ps = con.prepareStatement("INSERT INTO images VALUES (?, ?)");
ps.setString(1, file.getName());
byte[] b= new byte[fis.available()+1];
fis.read(b);
pst.setBytes(2,b);
int s = ps.executeUpdate();