Thread View: borland.public.cppbuilder.internet.socket
2 messages
2 total messages
Started by treehousetim
Mon, 12 Jun 2006 19:51
TIdHTTP
Author: treehousetim
Date: Mon, 12 Jun 2006 19:51
Date: Mon, 12 Jun 2006 19:51
18 lines
1625 bytes
1625 bytes
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
Re: TIdHTTP
Author: treehousetim
Date: Mon, 12 Jun 2006 21:25
Date: Mon, 12 Jun 2006 21:25
45 lines
2455 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads