Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

image upload in JSP

  Asked By: Ibthaj    Date: Jul 30    Category: Java    Views: 2302
  

i fall a small problem. I want to browse a picture then save it to my project folder. But i can't this small thing. Then i have done this with a bean. This is work well. But i want to do this simple pure JSP.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Boyce Fischer     Answered On: Jul 30

it is simple  code but it works.
tt is path file that you should get from form.
in FileOutput write the path that you want to save  image.

if (tt !=null && tt.length()>1){
InputStream ff = new FileInputStream(tt);
int size = ff.available();
byte[] bb = new byte[size];
ff.read(bb);
OutputStream fo = new FileOutputStream("C:/Documents and Settings/Shahab/jbproject/datting/WebModule1/images/"+uid+username+".jpg"); fo.write(bb);
}

 
Didn't find what you were looking for? Find more on image upload in JSP Or get search suggestion and latest updates.




Tagged: