🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #2300

Re: TIdHTTP

#2300
From: treehousetim
Date: Mon, 12 Jun 2006 21:25
45 lines
2455 bytes
Solved it:

Hope this helps someone.
Feel free to email me if you're curious about the php side of this.

Code:
FScreenShot is defined as a TJPEGImage
http is defined as a TIdHTTP component that was placed on the form.


FScreenShot->SaveToFile( "screenshot.jpg" );
TIdMultiPartFormDataStream *_Stream = new TIdMultiPartFormDataStream();

try
{
    _Stream->AddFile( "screenshot", "screenshot.jpg", "image/jpeg" );
    _Stream->AddFormField( "Field1", "A Regular Form Field"        );

    ResponseMemo->Text = http->Post( "http://example.com/example.php",
_Stream );
}
__finally
{
    delete _Stream;
}

treehousetim@gmail.com wrote:
> Hello,
>
> I'm using Indy 9.
>
> I'm trying to do an HTTP post to a server running apache with php.
> I'm attempting to upload a jpeg image, but every time I try the sample
> code I've found all over the internet, I get 406 errors from Indy, and
> my request never goes through to the server.
>
> Does anyone have sample code showing how to post a file upload using
> TIdHTTP to a php script?
>
> I'm quite versed in php - this really isn't a question about php file
> uploads, just how to get it to the php script in the first place.
> 
> Thanks!
> 
> - Tim
Technical Details
Message-ID: <1150147534.751361.162390@y43g2000cwc.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!y43g2000cwc.googlegroups.com!not-for-mail
References: <1150141917.488057.226750@g10g2000cwb.googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,ddbce70aea28169c
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!y43g2000cwc.googlegroups.com!not-for-mail
From: treehousetim@gmail.com
Newsgroups: borland.public.cppbuilder.internet.socket
Subject: Re: TIdHTTP
Date: 12 Jun 2006 14:25:34 -0700
Organization: http://groups.google.com
Lines: 46
Message-ID: <1150147534.751361.162390@y43g2000cwc.googlegroups.com>
References: <1150141917.488057.226750@g10g2000cwb.googlegroups.com>
NNTP-Posting-Host: 70.252.174.162
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1150147540 6040 127.0.0.1 (12 Jun 2006 21:25:40 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 12 Jun 2006 21:25:40 +0000 (UTC)
In-Reply-To: <1150141917.488057.226750@g10g2000cwb.googlegroups.com>
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: y43g2000cwc.googlegroups.com; posting-host=70.252.174.162;
   posting-account=S8s4tw0AAADI9BYK1Xz6MiVZklwpQ8Gw