You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by dijonsmit <di...@rws.com> on 2007/08/09 17:08:30 UTC
Re: [Fileupload]: Upload works in Firefox but no in IE
Hi, I am having the same problem. Have you figured out what the problem is?
Hoyer, Henning [ETHDE] wrote:
>
> Hi,
>
> this is a very interesting issue that has been bugging me for the past
> couple of days and I'm running out of ideas here.
> Hopefully one of you guys has had a similar issue before and can help.
>
> For starters, here is my form code:
>
> <form action="AttachDoc" method="post" enctype="multipart/form-data">
> <input type="hidden" name="question" id="question" value="<%=
> question.getId() %>" />
> <p class="right">
> <input type="file" id="document" name="document" />
> <input type="submit" value="Add Document" />
> </p>
> </form>
>
> and here is the servlet that handles the upload:
>
> protected void doGet(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException
> {
> int id = -1;
> int delete = -1;
> String fName = null;
> InputStream fInStream = null;
> String contentType = null;
> List items = null;
> Iterator iter;
> out = response.getWriter();
>
> if( ServletFileUpload.isMultipartContent(request) )
> {
> DiskFileItemFactory dfiFactory = new DiskFileItemFactory();
> ServletFileUpload upload = new ServletFileUpload( dfiFactory
> );
>
> try
> {
> items = upload.parseRequest( request );
> iter = items.iterator();
>
> while( iter.hasNext() )
> {
> FileItem fItem = (FileItem)iter.next();
>
> if( fItem.isFormField() )
> {
> String name = fItem.getFieldName();
> if( name.equals( "question" ) )
> {
> id = Integer.parseInt( fItem.getString() );
> }
> }//if( fItem.isFormField() )
> else
> {
> fName = fItem.getName();
> contentType = fItem.getContentType();
> //boolean isInMemory = fItem.isInMemory();
> //long sizeInBytes = fItem.getSize();
>
> fInStream = fItem.getInputStream();
> }
> }//while( iter.hasNext() )
> }
> catch( FileUploadException fue )
> {
> fue.printStackTrace( out );
> }
> }//if
> else
> {
> logger.info( "Request is not Multipart" );
>
> if( request.getParameter( "question" ) == null )
> {
> out.print( "Error: getting question ID." );
> return;
> }
>
> id = Integer.parseInt( request.getParameter( "question" ) );
> delete = request.getParameter( "delete" ) == null ? -1 :
> Integer.parseInt( request.getParameter( "delete" ) );
> }
>
> Question question = DfaqQuestions.getByID( id );
> if( question == null )
> {
> out.print( "Error: Can't get question." );
> return;
> }
>
> ...Rest left out for brevity...
>
> As you can see, the Form calls the servlet directly, no framework
> whatsoever is involved, just a couple of jsps and servlets.
> When I use Firefox (2.0.0.4) everything works great. With IE however, (IE
> 6) the request is completely empty. I also tried to
> print out the request data to system.out and it is true: With FF there is
> data (whole pdf file, form field etc.) , with IE the request
> contains absolutely _nothing_!
>
> While I'm sure that this has nothing to do with the library itself, I'm
> just hoping that one of you has seen this before.
>
> thanks much in advance,
> henning
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/-Fileupload-%3A-Upload-works-in-Firefox-but-no-in-IE-tf4028624.html#a12074149
Sent from the Commons - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org