Its probably a content-type error , the default content type I believe is
text/html.
Change it to
response.setContentType("application/octet-stream");
This will allow uploading of file types like gif, jpg,txt etc
Santosh
SUBSCRIBE JSP-INTEREST Gillian <[EMAIL PROTECTED]> on 07/19/2001 05:14:10 PM
Please respond to A mailing list about Java Server Pages specification and
reference <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: (bcc: Santosh Daryani/IT/Aon Consulting)
Subject: O'reilly Upload Problem
Hi,
I am trying to get file upload functionality working, using the O'reilly
multipart classes. I have some sample code that seems to work fine on other
installs, but on both my local machine and the development server we are working
on, I get the following error when the code is executed. I can upload .txt
files without a problem, but not .gif or .jpg files, regardless of size.
code fragment:
else if ( part.isFile() )
// it's a file part
filePart = (FilePart) part;
fileName = filePart.getFileName();
if ( fileName != null ) {
// the part actually contained a file
ByteArrayOutputStream bos = new ByteArrayOutputStream();
long size = 0;
try{
size = filePart.writeTo( bos );
} catch(IOException e){
System.out.println("writeTo(bos) exception = " + e.getMessage());
}
The exception that is caught is: "unexpected end of part"
Also, there is a servlet exception thrown: javax.servlet.ServletException:
Broken pipe
Please help!
Thanks,
Gillian
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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