indy multipart/form-data

indy  multipart/form-data

uses IdMultipartFormData;

procedure TForm1.ToolButton1Click(Sender: TObject);
//rest上传文件
var
  ms: TIdMultiPartFormDataStream;
begin
  if OpenDialog1.Execute then
  begin
    ms := TIdMultiPartFormDataStream.Create;
    ms.AddFormField('filename', '中国');
    ms.AddFile('file', OpenDialog1.FileName, '');
    url := url + 'restupload';
    IdHTTP1.Post(url, ms);
    ms.Free;
  end;
end;

  

posted @ 2020-03-26 10:27  delphi中间件  阅读(901)  评论(0编辑  收藏  举报