Thread View: borland.public.cppbuilder.internet.socket
10 messages
10 total messages
Started by David Ayre
Wed, 01 Nov 2006 10:59
HTTP put problem
Author: David Ayre
Date: Wed, 01 Nov 2006 10:59
Date: Wed, 01 Nov 2006 10:59
29 lines
1336 bytes
1336 bytes
Hi,
I'm using BDS 2006 with Indy 9 and have been trying to send a file
from disk to my website. This is my code:-
SL = new TMemoryStream;
SL->LoadFromFile(acPath);
try
{
IdHTTP1->Put("http://www.MySite.co.uk/aws/backup.zip",SL);
}
__finally
{
ListBox1->Items->Add("File sent");
}
catch(const Exception &)
{
return;
}
if(SL != 0)delete SL;
It seems to send the File OK but ends with and error message
saying that the connection was closed by a peer.
The file is not on the website.
Any ideas?
Cheers,
David
Re: HTTP put problem
Author: David Ayre
Date: Wed, 01 Nov 2006 15:00
Date: Wed, 01 Nov 2006 15:00
9 lines
917 bytes
917 bytes
The error message is:- Socket Error #10054 - Connection reset by peer. > >Cheers, > >David
Re: HTTP put problem
Author: Remy Lebeau (TeamB)
Date: Wed, 01 Nov 2006 21:30
Date: Wed, 01 Nov 2006 21:30
12 lines
1220 bytes
1220 bytes
"David Ayre" <davidcayre@ntlworld.com> wrote in message news:45488c35@newsgroups.borland.com... > This is my code:- Most servers do not support the PUT command at all. You will have to use a TIdMultipartFormDataStream, and your server-side script needs to be able to handle "multipart/form-data" postings. Gambit
Re: HTTP put problem
Author: David Ayre
Date: Thu, 02 Nov 2006 08:30
Date: Thu, 02 Nov 2006 08:30
12 lines
1298 bytes
1298 bytes
>Most servers do not support the PUT command at all. You will have to use a >TIdMultipartFormDataStream, and your server-side script needs to be able to >handle "multipart/form-data" postings. > >Gambit > So would it be better to use ftp for this? David
Re: HTTP put problem
Author: Remy Lebeau (TeamB)
Date: Thu, 02 Nov 2006 10:02
Date: Thu, 02 Nov 2006 10:02
12 lines
1340 bytes
1340 bytes
"David Ayre" <davidcayre@ntlworld.com> wrote in message news:4549baa0$1@newsgroups.borland.com... > So would it be better to use ftp for this? FTP is specifically designed for transferring files, afterall. Though there is nothing wrong with using "multipart/form-data" transmissions over HTTP, provided the server actually supports it. Gambit
Re: HTTP put problem
Author: David Ayre
Date: Thu, 02 Nov 2006 10:48
Date: Thu, 02 Nov 2006 10:48
24 lines
1580 bytes
1580 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote: > >"David Ayre" <davidcayre@ntlworld.com> wrote in message >news:4549baa0$1@newsgroups.borland.com... > >> So would it be better to use ftp for this? > >FTP is specifically designed for transferring files, afterall. Though there >is nothing wrong with using "multipart/form-data" transmissions over HTTP, >provided the server actually supports it. > > >Gambit > > Thanks Remy, I'm not sure how to use multipart/form-data. Do you think you could give me a few tips, please? Cheers, David
Re: HTTP put problem
Author: Remy Lebeau (TeamB)
Date: Thu, 02 Nov 2006 17:35
Date: Thu, 02 Nov 2006 17:35
43 lines
2273 bytes
2273 bytes
"David Ayre" <davidcayre@ntlworld.com> wrote in message
news:4549daf0$1@newsgroups.borland.com...
> I'm not sure how to use multipart/form-data. Do you think
> you could give me a few tips, please?
I already told you how to use it in your code - use the
TIdMultipartFormDataStream with the TIdHTTP::Post() method.
As far as the server is concerned, do any pages on your website have a
fillout form with a File button on it? If so, then you can submit the
TIdMultipartFormDataStream to the same URL that the form is submitted to.
In other words, if you have the following HTML:
<form method="Post" action="myscript.asp" enctype="multipart/form-data">
Select a file to upload: <input type="file" name="myfile"> <input
type="submit">
</form>
Then the code would look like this:
try
{
TIdMultipartFormDataStream *Strm = new TIdMultipartFormDataStream;
try
{
Strm->AddFile("myfile", acPath, "");
IdHTTP1->Post("http://www.MySite.co.uk/myscript.asp", Strm);
}
__finally
{
delete SL;
}
ListBox1->Items->Add("File sent");
}
catch(const Exception &)
{
return;
}
Gambit
Re: HTTP put problem
Author: David Ayre
Date: Thu, 02 Nov 2006 17:45
Date: Thu, 02 Nov 2006 17:45
10 lines
1282 bytes
1282 bytes
> TIdMultipartFormDataStream *Strm = new TIdMultipartFormDataStream; I tried that but it didn't recognise TIdMultipartFormDataStream. What do I need to #include? Thanks, David
Re: HTTP put problem
Author: David Ayre
Date: Thu, 02 Nov 2006 18:31
Date: Thu, 02 Nov 2006 18:31
22 lines
1719 bytes
1719 bytes
Hans Galema <notused@notused.nl> wrote: >David Ayre wrote: >>> TIdMultipartFormDataStream *Strm = new TIdMultipartFormDataStream; > >> I tried that but it didn't recognise TIdMultipartFormDataStream. >> What do I need to #include? > >#include <IdMultipartFormData.hpp> > >Then change p to P > > //TIdMultipartFormDataStream *Strm = new TIdMultipartFormDataStream; > TIdMultiPartFormDataStream *Strm = new TIdMultiPartFormDataStream; > ^ ^ >Hans. Thanks to both of you for your help. Cheers, David
Re: HTTP put problem
Author: Hans Galema
Date: Thu, 02 Nov 2006 19:15
Date: Thu, 02 Nov 2006 19:15
14 lines
1637 bytes
1637 bytes
David Ayre wrote:
>> TIdMultipartFormDataStream *Strm = new TIdMultipartFormDataStream;
> I tried that but it didn't recognise TIdMultipartFormDataStream.
> What do I need to #include?
#include <IdMultipartFormData.hpp>
Then change p to P
//TIdMultipartFormDataStream *Strm = new TIdMultipartFormDataStream;
TIdMultiPartFormDataStream *Strm = new TIdMultiPartFormDataStream;
^ ^
Hans.
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