Looks like you are trying to emulate a typical form post. The content type
typically used is multipart/form-data. The full content type header also
needs to indicate the boundary used within the post data to delineate the
different parts... here's some pseudo code.
        string    sCRLF = "\r\n";
        string    sDashes = "--";
        string    sBoundary = "some dashes and numbers and letters that does
not occur in element names|values|filedata";
        string    sMultipartContentType = "multipart/form-data; boundary=" +
sBoundary;

                 foreach (formfield) {
                    WriteString( stream, sDashes + sBoundary + sCRLF );
                    WriteString( stream, "Content-Disposition: form-data;
name= formfield.name<http://www.google.com/url?sa=D&q=http%3A%2F%2Ffield.name>
"
+ sCRLF );
                    WriteString( stream, sCRLF );
                    WriteString( stream, field.value);
                    WriteString( stream, sCRLF );
                }

                foreach (formfile) {
                    WriteString( stream, sDashes + sBoundary + sCRLF );
                    WriteString( stream, "Content-disposition: form-data;
name= 
formfile.name<http://www.google.com/url?sa=D&q=http%3A%2F%2Fattachment.name>;
filename=formfile.filename" + sCRLF );
                    WriteString( stream, sCRLF );
                    WriteStream( stream, formfile.filestream);
                    WriteString( stream, sCRLF );
                }

                 if ((formfields.Count > 0) || (formfiles.Count > 0))  {
                    WriteString( stream, sDashes + sBoundary + sDashes +
sCRLF );
                }


On Wed, Oct 29, 2008 at 1:32 PM, rakesh <[EMAIL PROTECTED]> wrote:

>
> I hav a simple code that attempts to use Desktop for multiple file
> upload to a server(a simple file upload servlet hosted on jboss and
> written using apache-file-upload).
>
> Once I open the request,
> this is how I set it to be multiplart content:
>        request.setRequestHeader("Content-type", "multipart/mixed");
>
> On the server I get the following exception:
>
> org.apache.commons.fileupload.FileUploadException: the request was
> rejected because no multipart boundary was found
>
>
> Am I missing something in the header? all help appreciated!!!
>

Reply via email to