1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| public class ajout_admin extends Action {
public ActionForward execute (ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)throws Exception
{
System.out.println("bonjour");
crh.form.ajout_admin image = (crh.form.ajout_admin)form ;
FormFile file=image.getFile();
System.out.println(file.getFileName());
try{
InputStream stream =file.getInputStream();
//OutputStream bos=new FileOutputStream("C:\\Users\\Utilisateur\\workspace\\CRH\\WebContent\\WEB-INF\\images");
OutputStream bos=new FileOutputStream("D:\\tof");
int bytesread=0 ;
while((bytesread=stream.read(buffer,0,8192))!=-1)
{
bos.write(buffer, 0, bytesread);
}
bos.close() ;
stream.close();
}
catch(Exception ex){System.out.println(ex.getMessage());return null ;}
file.destroy() ;
return mapping.findForward("OK");
} byte[] buffer = new byte[8192];
} |
Partager