ganondorfan
Amigo, posso lhe perguntar como você está fazendo a recuperação deste arquivo?
Javaxxxx
ganondorfan:
Amigo, posso lhe perguntar como você está fazendo a recuperação deste arquivo?
A recuperação é feita através do
:
<input type="file" name="imagem"/>
TesteServlet.java
...
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String imagem = request.getParameter("imagem");
gravar( imagem );
}
private void gravar( String imagem )
{
try
{
//URL url = this.getClass().getResource("paliofire.jpg");
File file = new File( imagem );
BufferedImage img = ImageIO.read( file );
ByteArrayOutputStream b = new ByteArrayOutputStream();
ImageIO.write( img, "jpg", b );
byte[] imgByte = b.toByteArray();
String sql = "INSERT INTO tb_imagens VALUES( NULL, ? )";
PreparedStatement stm = Conexao.getConexao().prepareStatement(sql);
stm.setBytes(1, imgByte);
stm.execute();
stm.close();
System.out.println( "gravado!" );
}
catch( SQLException e )
{
e.printStackTrace();
throw new RuntimeException( e.getMessage() );
}
catch( IOException ex )
{
ex.printStackTrace();
throw new RuntimeException( ex.getMessage() );
}
}