Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes Getting information from a Image file stored on client side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Getting information from a Image file stored on client side" Watch "Getting information from a Image file stored on client side" New topic
Author

Getting information from a Image file stored on client side

Ashish Saraf
Greenhorn

Joined: Sep 08, 2001
Posts: 14
i am using JSP in my application,
I want to store the image in the database
(in the BLOB datatype column).
For this client will select an image file from his
hard disk .
To select the file I am using file field tag in html i.e
<input type="file" name="blobFieldIns" >
when client will select the specific file using this tag
they will get a path like this
for e.g c:\example\link.jpg
so actually i planned to read the bytes of the file
using FileInputStream in the form of byte [ ] and store
this byte [] array in the database column.
( But this won't work b'coz file is selected is on client side).
so now i am planning to extract information from Image file
(i.e no of bytes)in the JavaScript.
so I want to Know how to do it in javaScript.
Does any one have the sample code???(if yes please send me).
please help me out,
regards,
Ashish.
Dave Van Even
Ranch Hand

Joined: Jul 19, 2001
Posts: 101
hi,
take a look at a package from Jason Hunter..
http://www.servlets.com/cos/javadoc/com/oreilly/servlet/MultipartRequest.html
You should assign "multipart/form-data" to the enctype attribute of the FORM tag! like this
<form enctype="multipart/form-data" action="blabla">

The file gets send to the client as a stream in the REQUEST, so there is no need to try and grab it from his HD yourself!
Take alook at how Jason does it, it's open source and try to figure out how you can do it to insert the retrieved file into the DB
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting information from a Image file stored on client side
 
Similar Threads
how to retrieve image in jsp page from a seperate folder.
disabling the html:image
Struts Survival Guide
Writing Image Bytes on Response Stream
Loading problem with t:inputFileUpload