Please suggest some ways to restrict type and size of file being uploaded through JSP.I want only image file(gif,jpeg,bitmap..).My action class is
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
NewsForm newsForm = (NewsForm) form;
FormFile myFile=null;
try{
myFile = newsForm.getTheFile();
String fileName = myFile.getFileName();
InputStream uploadInStream = myFile.getInputStream();
FileOutputStream fOut = new FileOutputStream("d:\\temp\\"
+ fileName);
int c=0;
while ((c=uploadInStream.read()) != -1) {
fOut.write(c);
} // while
fOut.flush();
fOut.close();
}
catch(FileNotFoundException fnfe){
}
Thanks.