Uploading Image File Through JSP Code To Server

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > JSP (Java Server Pages)

Uploading Image File Through JSP Code To Server

sendto
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 :
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

 

 

 


Reply

uapconsole
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

Reply

Ola Daniel
QUOTE
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.

 

 

 


Reply

masiel
cm hago por favor a tener mi prpoa bae de datos en esta web, con JSP para guardar mis datos y consultarla despues

Reply

iGuest
Please exclude your own package

-chirag

Reply

iGuest
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

Reply

iGuest
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

Reply

iGuest
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

Reply

iGuest
Dears

How 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

Reply

iGuest
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

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. how can we upload images in jsp - 0.87 hr back. (1)
  2. code for uploading a image in java - 1.08 hr back. (1)
  3. upload image in jsp - 1.54 hr back. (1)
  4. upload images jsp - 2.93 hr back. (1)
  5. uploding photos to server using jsp - 4.98 hr back. (1)
  6. upload file jsp - 5.15 hr back. (1)
  7. uploading images to a database with jsp - 10.69 hr back. (1)
  8. jsp image upload sample - 11.57 hr back. (1)
  9. how to upload picture using jsp in database - 12.80 hr back. (1)
  10. upload file jsp html to database - 13.48 hr back. (1)
  11. input file jsp - 16.37 hr back. (1)
  12. upload images to server html code - 16.55 hr back. (1)
  13. jsp image file - 17.30 hr back. (1)
  14. jsp how to upload image - 18.71 hr back. (1)
Similar Topics

Keywords : uploading image file jsp code server


    Looking for uploading, image, file, jsp, code, server

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for uploading, image, file, jsp, code, server
advertisement




Uploading Image File Through JSP Code To Server



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE