delphi idhttp post施用

delphi idhttp post应用

delphi idhttp post应用

 

  1. uses IdMultipartFormData;
  2. { .... }
  3. procedure TForm1.Button1Click(Sender: TObject);
  4. var
  5.   data: TIdMultiPartFormDataStream;
  6. begin
  7.   data := TIdMultiPartFormDataStream.Create;
  8.   try
  9.     { add the used parameters for the script }
  10.     data.AddFormField('param1''value1');
  11.     data.AddFormField('param2''value2');
  12.     data.AddFormField('param3''value3');
  13.     { Call the Post method of TIdHTTP and read the result into TMemo }
  14.     Memo1.Lines.Text := IdHTTP1.Post('http://localhost/script.php', data);
  15.   finally
  16.     data.Free;
  17.   end;
  18. end;