i want to upload pictures in a folder rather then Mysql database ,please give me direction to uploading images in a folder

Recommended Answers

All 2 Replies

If you had searched forum you would found few answers like this one for start

i want to upload pictures in a folder rather then Mysql database ,please give me direction to uploading images in a folder

import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class JdbcInsertImage extends  HttpServlet{
public void doGet(HttpServletRequest request, 
HttpServletResponse response) throws ServletException, IOException
{
PrintWriter pw = response.getWriter();
String connectionURL = "jdbc:mysql://localhost:3306/roseindia";
java.sql.Connection connection=null;
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, 
"root", "root");
PreparedStatement pst = connection.prepareStatement
("insert into image values(?,?)");
File file = new File("C:/apache-tomcat-5.5.20/webapps
/mywork/grad_sm.gif");
FileInputStream fis = new FileInputStream(file);
pst.setBinaryStream(1,fis,fis.available());
pst.setString(2, "Tim");
int i = pst.executeUpdate();
if(i!=0)
{
pw.println("image has been inserted");
}
else
{
pw.println("image is not inserted");
}	
}
catch (Exception e)
{
System.out.println(e);
}
}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.