Yes you can use the multipartRequest servlet to upload an image
in the readNextPart() method you can check if contentType.indexOf("image")
and do something like this
// Get the blob locator and open an output stream for the blob
theBlob = ((OracleResultSet)getBlobResult).getBLOB("image");
blobStream = theBlob.getBinaryOutputStream();
// Read a chunk of data from the sample file input stream, and
write the
// chunk into the blob column output stream. Repeat till file has
been
// fully read.
byte[] bbuf = new byte[8 * 1024];
int result;
String line;
// the point of this code from Hunter is to remove an
// exraneous '\r\n' from the end of the servlet input stream
boolean rnflag = false;
while ((result = in.readLine(bbuf, 0, bbuf.length)) != -1) {
// Check for boundary
if (result > 2 && bbuf[0] == '-' && bbuf[1] == '-') { // quick
pre-check
line = new String(bbuf, 0, result, "ISO-8859-1");
if (line.startsWith(boundary)) break;
}
// Are we supposed to write \r\n for the last iteration?
if (rnflag) {
blobStream.write('\r'); blobStream.write('\n');
rnflag = false;
}
// Write the buffer, postpone any ending \r\n
if (result >= 2 &&
bbuf[result - 2] == '\r' &&
bbuf[result - 1] == '\n') {
blobStream.write(bbuf, 0, result - 2); // skip the last 2
chars
rnflag = true; // make a note to write them on the next
iteration
}
else {
blobStream.write(bbuf, 0, result);
}
}
System.out.println("finished writing blob field 'image' in
table \n");
blobStream.close();
hope this helps
>From: Gagan Goel <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
> reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Upload Image File
>Date: Thu, 17 Aug 2000 19:43:43 +0530
>
>Is there any way to upload an image with MultiPartRequest (or
> somehow else)?
>
>Gagan
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets