idhttp post file - multipart form data with indy?
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