FileUpload to servlet from a C++ class ?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Amit_Bakore
Posted On:   Friday, April 27, 2001 05:10 AM

Hi, I hv written a C++ class (currently implemented using MFC) to upload multiple files to a servlet/JSP. It uses 'multipart/form-data' encryption type. Before asking question, here I put a brief info bout what I did : //code snippet using the CHttpConnection class CString m_server = "http://myserver"; CString m_pconnection = m_session.GetHttpConnection ( "myserver",80,NULL,NULL,NULL) ; CHttpFile *m_pfile; //set contet string i.e. files to be uploaded. LPCTSTR content = "/servletupload/servlet/requestupload?file1=c:%5camit1.txt&file2=c:%5camit2. txt"; //setting headers const TCHAR szHeaders[]    More>>

Hi,

I hv written a C++ class (currently implemented using MFC) to upload
multiple files to a servlet/JSP.
It uses 'multipart/form-data' encryption type.
Before asking question, here I put a brief info bout what I did :

//code snippet using the CHttpConnection class
CString m_server = "http://myserver";
CString m_pconnection = m_session.GetHttpConnection (
"myserver",80,NULL,NULL,NULL) ;
CHttpFile *m_pfile;

//set contet string i.e. files to be uploaded.
LPCTSTR content =
"/servletupload/servlet/requestupload?file1=c:%5camit1.txt&file2=c:%5camit2.
txt";

//setting headers
const TCHAR szHeaders[] =
_T("connection:Keep-Alive

accept-encoding:gzip,deflate

accept:image/gif, image/x-xbitmap, image/jpeg, */*

cache-control:no-cache

accept-language:en-us
user-agent:Mozilla/4.0 (compatible; MSIE 5.5;
Windows NT 4.0)

content-type:multipart/form-data
boundary=---------------------------7d138818e03b6
content-length=41
")
;

//open connection
m_pfile = m_pconnection -> OpenRequest ("POST",content,NULL,1,NULL,NULL,
(DWORD)INTERNET_FLAG_EXISTING_CONNECT);

//add headers
m_pfile->AddRequestHeaders(szHeaders);

//send request
m_pfile -> SendRequest( ) ;

--------------------------
MY QUESTION

After doing this I get following error,
"java.io.IOException: Corrupt form data: premature ending"

Is there anyone who would like to give some tip how to 'set headers' or why
this might be happening ?

Regards & TIA,
-Amit.

   <<Less
About | Sitemap | Contact