commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Cooper" <>
Subject Re: NEWBIE FileUpload question
Date Tue, 06 Apr 2004 19:10:00 GMT
I am not at all familiar with the XMLHTTP code you are using to create the
request, but I'm guessing that the problem may lie in the structure of the
request itself. If you could capture the raw request that is being submitted
(e.g. using Windows Network Monitor or Ethereal), that would help a lot.

Martin Cooper

"Giovannini Andrea" <> wrote in message
I'm using FileUpload to process a file uploaded from Internet Explorer
via Jscript, there's no direct form submit but I use the XMLHTTP object
since I want control over the result. This is my client code

function go() {
    // I skip some details
    var fileName = ...;
    var url = ... + "&fileName=" + fileName;

    var adoStream = new ActiveXObject("ADODB.Stream");
    adoStream.Mode = 3;
    adoStream.Type = 1;
    var xmlhttp = new ActiveXObject("MSXML2.XMLHTTP");"POST", url, false);

    var boundary = "----------This_Is_The_Boundary_\r\n";
boundary=" + boundary);
    xmlhttp.setRequestHeader("Content-Length", adoStream.Size);

Then I want to save the file on the server. In my servlet I have this

String path = ...
DiskFileUpload upload = new DiskFileUpload();

try {
List items = upload.parseRequest(request);
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem);
if (!item.isFormField()) {
fileName = item.getName();
File uploadedFile = new File(fileName);
} catch(Exception e) {

But the parseRequest() returns an empty list. I've debugged the
FileUpload code and the problem is that in the discardBodyData() of the
class MultipartStream a MalformedStreamException("Stream ended
unexpectedly") is thrown and parseRequest() returns an empty collection.
So I wonder what's wrong with my uploading... Any idea?

Thanks in advance,

Andrea Giovannini
Java Software Architect

Gruppo Formula S.p.A.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message