Upload and scale image
Hi,
I'm fairly new to jsp
I need to upload an image file (.jpg or .gif) using
<INPUT TYPE='file' NAME='test'> inside the form tag (action to upload.jsp)
my question, what should i do inside my upload.jsp.. I just need to save it in a directory at the server
Moreover, I should also scale the image to 100x100 size
Any reference or library or VERY VERY simple sample code is very helpful to me
Thanks
[459 byte] By [
winedza] at [2007-11-27 7:29:20]

# 2
Your code:
<%@ page session="false" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.io.*" %>
<%@ page contentType="image/jpeg"%>
<%
try{
FileInputStream fi = new FileInputStream("c:/dir/image.jpg");
OutputStream output =response.getOutputStream();
while(true)
{
int d = fi.read();
output.write(d);
if(fi.available()==0)
{
fi.close();
output.close();
}
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
%>
- how do i know the filename uploaded ? I only need to know the extension
- how do i resize the image into 100x100 if it's bigger than 100 ? what image property should i use ?