試下如下:uses IdMultipartFormData; { .... } procedure TForm1.Button1Click(Sender: TObject); var data: TIdMultiPartFormDataStream; begin data := TIdMultiPartFormDataStream.Create; try { add the used parameters for the script } data.AddFormField('param1', 'value1'); data.AddFormField('param2', 'value2'); data.AddFormField('param3', 'value3'); { Call the Post method of TIdHTTP and read the result into TMemo } Memo1.Lines.Text := IdHTTP1.Post('http://localhost/script.php', data); finally data.Free; end; end;
var
data: TIdMultiPartFormDataStream;
begin
data := TIdMultiPartFormDataStream.Create;
try
{ add the used parameters for the script }
data.AddFormField('param1', 'value1');
data.AddFormField('param2', 'value2');
data.AddFormField('param3', 'value3'); { Call the Post method of TIdHTTP and read the result into TMemo }
Memo1.Lines.Text := IdHTTP1.Post('http://localhost/script.php', data);
finally
data.Free;
end;
end;
那个是正常的,但现在是传一个文件流,在服务器从新写文件,写出来的文件乱码.