Jump to content
xisto Community
welcome77in

Uploading Image File Through JSP Code To Server

Recommended Posts

I have to upload images from client side to server side, without using input tag or browseing of file. I know the absolute path of file in client side. And that file I want to shift to server with JSP code or any servlet code. I have done uploading through servlet to the server with input tag and type is file .

 

Servlet code :

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");}}

This code needs oreilly Image package API

Can anyone help me to upload to file without using

 

<form method=post type =encrpted>

 

<input type=âfileâ name= âuploadfileâ>

 

 

 

if I use <input type=âfileâ name= âuploadfileâ value=âc:\temp\myphoto.jpgâ>

it doesnât work..

 

Notice from moonwitch:
We require you to pour large chunks of code into the code tags.

Reduced Credits by 6 days


Share this post


Link to post
Share on other sites

I am using Sun Studio Creator 2 to deploy the calendar control in the web browser, using JSP. When I compile with the calendar control, its fine and it displays properly on Firefox, but it doesn't display properly on Internet Explorer. Is this a common mobility problem with this control? I believe there might be another explanation. I'd appreciate any help, thank you. - Demirelli

Share this post


Link to post
Share on other sites

This code needs oreilly Image package API

Can anyone help me to upload to file without using

 

<form method=post type =encrpted>

 

<input type=âfileâ name= âuploadfileâ>

 

if I use <input type=âfileâ name= âuploadfileâ value=âc:\temp\myphoto.jpgâ>

it doesnât work..

 


Sendo of course doing this "<input type=âfileâ name= âuploadfileâ value=âc:\temp\myphoto.jpgâ>" will not work. You are attempting to breach the security of your client machine. Imagine the havoc a web developers could wreak on a client machine if he could pick files from the client's machine at will without active participation from the client.

 

You cannot, i repeat cannot upload a file from a client machine without PERMISSION being given to you by the client.

 

I would suggest using an applet to copy the file from the client machine since you know the location of what you need the upload. Of course your applet has to be signed and your user has to accept your applet certificate. This way he has given you persmission to read and write files from his machine.

 

If you do not understand my explanation. let me know i will be more than happy to explain further.

Edited by Ola Daniel (see edit history)

Share this post


Link to post
Share on other sites

how to copy an image from one location to other using jsp code,having apache web server 6.0?

Uploading Image File Through JSP Code To Server

 

Q> How to copy an image from one location to other using jsp code,having apache web server 6.0?

 

-Shubhadip Bera

Share this post


Link to post
Share on other sites

image uploading problem

Uploading Image File Through JSP Code To Server

 

Hi,

 

My problem is I have the path of the image now I need to write a jsp to send this file to web server that is on client machine.Please help how to do it.

 

 

 

-smita

Share this post


Link to post
Share on other sites

files in JSP

Uploading Image File Through JSP Code To Server

 

How to input file and how to store and fetch it from database in jsp with database MS Access 2000

 

-reply by Gautam Verma

Share this post


Link to post
Share on other sites

DearsHow to store a uploaded JPEG file ino the database and how to disppaly it in JSP page. Please give me the code.Pankaj Kumar-reply by pankaj

Share this post


Link to post
Share on other sites

uploading of image files in jsp

Uploading Image File Through JSP Code To Server

 

I want to upload image files to the server ,give me the idea or coding to upload the image file

 

-question by karthi

Share this post


Link to post
Share on other sites
Uploading images to serverUploading Image File Through JSP Code To ServerReplying to Ola DanielHi there!Can you Please tell me how to upload an image to a specific folder on the web server. M doing it in JSP and asking the user to browse through file upload component.Thankx.-
 
reply by Ashish

Share this post


Link to post
Share on other sites
upload file from client to serverUploading Image File Through JSP Code To Server

when I upload using <file> tag, it's not work upload file from client machine but only from server machine ... So I just only got no file found error. ... How should I do?

-reply by nwaynge

Share this post


Link to post
Share on other sites
what is the actual format of setting webapps and WEB-INF? where to save jsp files in apache tomcat server?Uploading Image File Through JSP Code To Server

Hello,

Please tell me that how to save the jsp file?what is the right way/path of saving the xml files, jsp files, pojo(pure java files) after insatalling the apache tomcat server where should be placed or saved these all files to compile it or run it?

reply soon ...I m waiting

regards..

-question by Maggi

Share this post


Link to post
Share on other sites
What is the target path of server when we create a file on server using jspUploading Image File Through JSP Code To Server

I am having a folder like in our application "http://forums.xisto.com/no_longer_exists/;

Now I need to create a file in the folder, I tried like

File f=mew File(" http://forums.xisto.com/no_longer_exists/;);

but the server does not recognizing the path, it says invalid directory,path

tell me what should I give here 

File f=mew File(" ??????");

Please... Help me

-reply by Asgar

Share this post


Link to post
Share on other sites
can i change the path of uploading image?Uploading Image File Through JSP Code To Server

I have upload a image file using above code...It is working when it deployed in Tomcat..If I use Weblogic server it is storing in some other place.So, My question is...Can I change the path of uploading image?

please reply soon ...

thanks 

Ashok

-reply by Ashok

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.