• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Upload

 
vishal sodani
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have an HTML page,in which user fills two textboxes(name and biography details) and in third textbox gives the path of an image to be uploaded.How can I upload all the three information to webserver and then save it to a database using JSP
thanks
vishy
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have many options.
you can write the whole database code in the same jsp page, or use a form to submit it to a servlet which will handle it or use a bean that will act as the link to the database.
in all options u get the parameters in the textfields using the
request.getParameter(name of field);
then u can whatever u wish with it.
 
vishal sodani
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but what about the image,whose path is given in the textbox?what will I have to write to upload the image from the local disk?
thanks
 
Naveen Sydney
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vishal sodani:
but what about the image,whose path is given in the textbox?what will I have to write to upload the image from the local disk?
thanks

when u use the <input type='file'> the actual file gets submitted not just the path in the textbox. Do refer to multipart mimetypes(O'Reiley has one that u can download for free).
Also after you have uploaded the image from the clients computer to your webserver u need to save it in the database. if u are using oracle there are specific datatypes u can declare to store images. But my suggestion is to write the image into the webservers hard drive and store the path in the database.
regards
syd
 
vishal sodani
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anyone help me with an example with code how to parse a multipart/form-data.In my case,I have two textbox and an image to upload.
thanks
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to use one of the packages that are available out there. It's not that straight forward. O'reilley has one out there, as mentioned previously. You can search this forum or www.google.com for some links.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic