Jump to content
xisto Community
welcome77in

Uploading Image File Through JSP Code To Server

Recommended Posts

import com.Oreilly.Servlet.MultipartRequest;Import java.Io.*;Import java.Util.*;Import javax.Servlet.*;Import javax.Servlet.Http.*;public class UploadPhoto extends HttpServlet {Public void doPost(HttpServletRequest req, HttpServletResponse res) Throws ServletException , IOException {Res.SetContentType("text/html");PrintWriter out = res.GetWriter();String rtempfile = File.CreateTempFile("temp","1").GetParent();MultipartRequest multi = new MultipartRequest(req, rtempfile, 500 * 1024); File rnewfile=null;Rnewfile = new File(new File("/").GetAbsolutePath()+File.Separator+"tomcat"+File.Separator+"webapps"+File.Separator+"ROOT"+File.Separator+"Photo"+File.Separator+"YourPhotoname.Jpg");Out.Println("<HTML>");Out.Println("<head><title>UPLOAD PHOTO</title></head>");Out.Println("<body>");Out.Println("<Pre>");Enumeration files = multi.GetFileNames();While (files.HasMoreElements())  {File f = multi.GetFile(name);FileInputStream fin =new FileInputStream(f);ImageInfo ii =new ImageInfo();Ii.SetInput(fin);Fin.Close();   fin =new FileInputStream(f);   FileOutPutStream fos =new  FileOutPutStream(rnewfile);   byte sizefile[] = new byte[500000];   fin.Read(sizefile);   fin.Write(sizefile);   fos.Close(); Fin.Close();F.Delete();}Res.SendRedirect("Your.Jsp");}}

Share this post


Link to post
Share on other sites
sending an image from client to clientUploading Image File Through JSP Code To Server

actually I m developing a chat server in java with the help of sockets but I am unable to send images from one client to other one.Please help me  to provide this code as soon as possible.

thank you in advance.

-question by arya

Share this post


Link to post
Share on other sites
webservice from server to clientUploading Image File Through JSP Code To Server

hi

I need to play a video saved on webserver which is requested by client  to view in his mobile device

how to write webservice for the above

Any one pls help me out 

suggest me any solutions 

Thanx in advance ...

Regards 

Nisha

Share this post


Link to post
Share on other sites
image is not shownUploading Image File Through JSP Code To Server

I had uploaded the picture and saved the path into database..But I am not able to retrieve the picture..Path is gettable but image is not shown..Below is the code..Do suggest some help..

-reply by R.A.Sethi

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.