Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  yordan : (16 June 2013 - 05:41 PM) You're Welcome, Agyat!
@  agyat : (16 June 2013 - 07:38 AM) Thanks Yordan...
@  velma : (16 June 2013 - 12:06 AM) I Have Asked Opa To Check For A Backup.. He'll Let Me Know Soon :)
@  velma : (16 June 2013 - 12:05 AM) T_T It Seems That Someone Has Deleted That Topic Since I Found The Url Of The Topic But It Gives Me An Error
@  yordan : (15 June 2013 - 10:31 PM) @velma : It's A Tuto On How To Create A Login Program.
@  yordan : (15 June 2013 - 10:31 PM) Happy Birthday To Youuuuuu Agyat!
@  yordan : (15 June 2013 - 10:31 PM) Ba$
@  agyat : (15 June 2013 - 04:41 PM) :(
@  agyat : (15 June 2013 - 04:41 PM) Where The Hall I Were? 15Th Is Almost At End And No-One Wished Me "happy Birthday"!!!
@  velma : (14 June 2013 - 10:39 AM) Which Tutorial Is He Searching For?
@  velma : (14 June 2013 - 10:38 AM) Which Tutorial Is He Searching For?
@  yordan : (14 June 2013 - 07:47 AM) Ok, Have A Look Tomorrow.
@  yordan : (13 June 2013 - 03:19 PM) @velma, Can You Have A Look At Feelay's Problem? Seems That His Tutorial Is Not Searchable Today.
@  Feelay : (13 June 2013 - 08:11 AM) Oh, Haha
@  velma : (12 June 2013 - 05:39 PM) T_T Lately My Levels Of Procrastination..... **sigh**
@  velma : (12 June 2013 - 05:38 PM) I'll Do It Later
@  velma : (12 June 2013 - 05:38 PM) Procrastinators.. People Who Keep Saying "i'll Do This In A Bit"
@  Feelay : (12 June 2013 - 02:05 PM) Deal Punishments To What?
@  velma : (12 June 2013 - 01:27 PM) T_T We Should Deal Punishments To Procrastinators... Especially Me
@  Feelay : (12 June 2013 - 12:06 PM) As Well As Making It More Secure.

Photo
- - - - -

Uploading Image File Through JSP Code To Server


18 replies to this topic

#1 sendto

sendto

    Newbie [ Level 1 ]

  • Members
  • 3 posts

Posted 03 January 2006 - 02:14 PM

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..

[note=moonwitch]We require you to pour large chunks of code into the code tags.
Reduced Credits by 6 days[/note]

#2 uapconsole

uapconsole

    Newbie [ Level 2 ]

  • Members
  • 24 posts

Posted 28 February 2006 - 10:06 PM

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

#3 Ola Daniel

Ola Daniel

    Newbie [ Level 2 ]

  • Members
  • 15 posts
  • Interests:J2EE, Java, AJAX, Oracle, MSSQL, MySQL

Posted 15 June 2006 - 08:55 PM

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, 15 June 2006 - 08:57 PM.


#4 masiel

masiel

    Newbie [ Level 1 ]

  • Members
  • 1 posts

Posted 13 July 2007 - 05:00 PM

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

#5 Guest_FeedBacker_*

Guest_FeedBacker_*
  • Guests

Posted 02 October 2007 - 11:46 AM

Please exclude your own package

-chirag

#6 Guest_FeedBacker_*

Guest_FeedBacker_*
  • Guests

Posted 29 January 2008 - 07:14 PM

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

#7 Guest_FeedBacker_*

Guest_FeedBacker_*
  • Guests

Posted 09 February 2008 - 11:00 AM

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

#8 Guest_FeedBacker_*

Guest_FeedBacker_*
  • Guests

Posted 08 May 2008 - 05:49 AM

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

#9 Guest_FeedBacker_*

Guest_FeedBacker_*
  • Guests

Posted 09 June 2008 - 09:04 AM

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

#10 Guest_iGuest-karthi_*

Guest_iGuest-karthi_*
  • Guests

Posted 30 July 2008 - 12:06 PM

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

#11 Guest_(G)Ashish_*

Guest_(G)Ashish_*
  • Guests

Posted 01 December 2008 - 06:38 PM

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


#12 Guest_(G)nwaynge_*

Guest_(G)nwaynge_*
  • Guests

Posted 26 December 2008 - 12:59 PM

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



#13 Guest_(G)Maggi_*

Guest_(G)Maggi_*
  • Guests

Posted 23 April 2009 - 04:45 AM

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

#14 Guest_(G)Ashok_*

Guest_(G)Ashok_*
  • Guests

Posted 02 September 2009 - 02:10 AM

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

#15 Guest_(G)Asgar_*

Guest_(G)Asgar_*
  • Guests

Posted 29 August 2009 - 04:42 AM

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 "www.Dname.Com/admin/video/"

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

File f=mew File(" www.Dname.Com/admin/video/filename.Txt");

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

#16 Guest_(G)_*

Guest_(G)_*
  • Guests

Posted 26 December 2009 - 07:16 AM

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



#17 Guest_(G)arya_*

Guest_(G)arya_*
  • Guests

Posted 03 April 2010 - 12:02 PM

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

#18 Guest_(G)Nisha_*

Guest_(G)Nisha_*
  • Guests

Posted 22 July 2010 - 11:08 AM

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



#19 Guest_(G)R.A.Sethi_*

Guest_(G)R.A.Sethi_*
  • Guests

Posted 07 May 2011 - 05:30 AM

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..

<%@ page import="java.Io.*,com.Oreilly.Servlet.*" %><%@ page import="java.Sql.*"%><%@ page import="java.Io.*"%><% try {String rno=(String)session.GetAttribute("reg_no"); String tname=null; String aname=null; String cname=null;Final int limit=1024*1024*1024; Class.ForName("oracle.Jdbc.Driver.OracleDriver"); Connection con=DriverManager.GetConnection("jdbc:oracle:thin:@127.0.0.1:1521:xe","anand","sethi"); int I=0; String saveDir=application.GetRealPath("photo"); File f=new File(saveDir); f.Mkdirs(); MultipartRequest mpr=new MultipartRequest(request,application.GetRealPath("photo"),limit); String s1=mpr.GetOriginalFileName("file"); String path=application.GetRealPath("photo"+""+s1); Statement st=con.CreateStatement(); I = st.ExecuteUpdate("update profile set p_path='"+path+"' where reg_no='"+rno+"'"); if(I==1) { out.Println("done"); } else out.Println("not done"); } catch(Exception e) { out.Print("in sql exception"+e); }%>-reply by R.A.Sethi





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users