Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

idhttp post file - multipart form data with indy?

2 views
Skip to first unread message

Chris Veale

unread,
Sep 22, 2002, 11:43:08 PM9/22/02
to

hi

I am trying to upload a file to an https server through indy 9.0

I have looked at the articles on the nevrona site and an doing what they say, but...

when I do this - addfile procedure I get an error message "unable to open file"

var
ResponseStream: TMemoryStream;
MultiPartFormDataStream: TidMultiPartFormDataStream;
begin
Form1.OpenDialog1.Title := 'are you sure you want to upload information';
if form1.OpenDialog1.Execute then
begin
MultiPartFormDataStream := TidMultiPartFormDataStream.Create;
ResponseStream := TMemoryStream.Create;
try
form2.IdHttp1.Request.ContentType := MultiPartFormDataStream.RequestContentType;
MultiPartFormDataStream.AddFormField('PersonName', form2.Edit1.Text);
MultiPartFormDataStream.AddFile('c:\file.doc', form1.opendialog1.Files.Text, 'application/msword');
{ You must make sure you call this method *before* sending the stream }
// MultiPartFormDataStream.PrepareStreamForDispatch;
MultiPartFormDataStream.Position := 0;
form2.IdHTTP1.Post('https://webdev.hort.cri.nz\test\post_test.php', MultiPartFormDataStream, ResponseStream);
finally
MultiPartFormDataStream.Free;
ResponseStream.Free;
end;
end;

can anyone please help with this? I desperately need to be able to upload a file to our https server

can anyone help with advice, pointers to more articles or examples?

Cheers

Chris

0 new messages