Re: Anyone know how to use CHttpFile to upload a file to a server?

From: Henchman:crg (colin_at_colingirling.my-bulldog.com)
Date: 12/22/04


Date: Wed, 22 Dec 2004 18:48:25 -0000

What do I need to parse within the binary data?
Also, I am sending form data with the binary file, should I send that using
a seperate SendRequest?

"Random User" <qvnmfddujfu@mailinator.com> wrote in message
news:OcRS$BD6EHA.1300@TK2MSFTNGP14.phx.gbl...
> Unless your strFormData is properly formatted, it's meant to fail. You can
> either format it the same way as GET parameters
> (formdata=h%20e%20l%20l%20o), which is very easy to get in ASP, or as
> multipart form data, which needs to be manually parsed in ASP.
>
> For transmitting binary files we found the latter more suitable. Proper
> formatting for multipart form data is sort of a mess, but you can sniff
> what
> IE sends and/or read formal description.
>
> But the rest of the code looks ok [if compiled].
>
> "Henchman:crg" <colin@colingirling.my-bulldog.com> wrote in message
> news:LNadnZMfI_aH41XcRVnyuA@giganews.com...
>> Got some sample code here, just not sure what else I need to do.
>> Trying to post a asp page and get a binary file transmitted to the
>> server.
>>
>> CString strHttpSite = "www.myserver.com";
>> CInternetSession *pInetSession = new CInternetSession(strHttpSite, 1,
>> INTERNET_INVALID_PORT_NUMBER);
>>
>> DWORD dwServiceType;
>> CString strServerName;
>> CString strObject;
>> INTERNET_PORT nPort;
>> AfxParseURL(strHttpSite, dwServiceType, strServerName, strObject, nPort)
>>
>> CHttpConnection *pHttpConnection =
>> pInetSession->GetHttpConnection(strServerName);
>>
>> CHttpFile *pHttpFile =
>> pHttpConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,
> "upload.asp",
>> NULL, 1, NULL, NULL,
>>
> INTERNET_FLAG_EXISTING_CONNECT|INTERNET_FLAG_RELOAD|INTERNET_FLAG_DONT_CACHE
> );
>>
>> DWORD dwStatusCode = 0;
>> if( pHttpFile->SendRequest() ) //strHeaders,
>> const_cast<char*>(static_cast<const char*>(strFormData)),
>> strFormData.GetLength()) )
>> pHttpFile->QueryInfoStatusCode(dwStatusCode);
> P.S. This code is not going to compile.
>
>



Relevant Pages

  • Re: Anyone know how to use CHttpFile to upload a file to a server?
    ... > I am now parsing the form data, but still cannot get this to work. ... > binary file, but don't understand what I am doing wrong. ... >> either format it the same way as GET parameters ... >> multipart form data, which needs to be manually parsed in ASP. ...
    (microsoft.public.vc.mfc)
  • Re: Anyone know how to use CHttpFile to upload a file to a server?
    ... I am now parsing the form data, but still cannot get this to work. ... binary file, but don't understand what I am doing wrong. ... > either format it the same way as GET parameters ... which needs to be manually parsed in ASP. ...
    (microsoft.public.vc.mfc)
  • Re: C Program Portability
    ... Now, since this is a binary file, any transfer is likely to ... that any code writing data as a binary file needs to be adapted for the ... It's more that if you are dealing with reading, processing, writing a ... binary format (say, doing some image processing on a greyscale image ...
    (comp.lang.c)
  • Re: Debug Assertion Failure
    ... I would read/write structure bytes to file *only* if it is a plain ... in these cases a finer serialization mechanics is required. ... because it's a text format, not a binary format), or using MFC ... Is 'offset' consistent with your binary file format? ...
    (microsoft.public.vc.mfc)
  • Re: storing dataset
    ... The CSV file format is convenient and widely ... and then back again when reading them is a big pain. ... binary file, you cannot be sure even that the same source code ... compiled with a different compiler or even a different version of the ...
    (microsoft.public.dotnet.framework)