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

From: Random User (qvnmfddujfu_at_mailinator.com)
Date: 12/22/04


Date: Wed, 22 Dec 2004 09:14:00 -0500

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: Best way to deal with user forms
    ... Thanks for the response. ... Your point is taken about sending email only in text format. ... > If your site is hosted on a Windows IIS server and you can use ASP and Access, ... > accomplished using the FP database components with no additional cost involved. ...
    (microsoft.public.frontpage.client)
  • Re: Leading Zeros dropped in date returned from SQL Data using ASP
    ... I am moving a fairly simple .ASP page from a W2000/IIS5 to a W2K3/IIS6 ... commonly understand are merely renderings for output. ... Language settings applet, assuming you have admin access to. ... I have checked Short Date format in Regional Settings. ...
    (microsoft.public.inetserver.asp.db)
  • Re: Ordering by date ???
    ... are stored as numbers without format. ... applications (such as ASP) cannot use this property. ... user, IUSR_machinename, unless a Locale change is made in the code, or a ... Please reply to the newsgroup. ...
    (microsoft.public.inetserver.asp.db)
  • Re: Inserting time and date in datetime field
    ... You could format a string in your ASP page with the date and time values ... Insert the string into your dateTime column in this format. ... >> Drew Laing ...
    (microsoft.public.inetserver.asp.db)
  • Gibt es eine STR() Funktion wie in Visual Basic 6.0 in VBScript for ASP ?
    ... gibt es asp soetwas wie die StrFunktion in VB. ... eingegeben wird immer in das Format z.B 4.23 ... Benötige dies zur Übergabe von Währungsbeträgen an ein SQL Statement welches ...
    (microsoft.public.de.inetserver.iis.asp)