用IDHTTP 实现上传和返回XML

{idHTTP}

 

procedure upload;

var
  tmpWeb: TIdHTTP;
  FS: TIdMultiPartFormDataStream;
begin

  try
    tmpWeb:=TIdHTTP.Create(nil);

    FS := TIdMultiPartFormDataStream.Create;

    FS.AddFormField('postconntext', '');  //上传参数

    FS.AddFile('userfile', trim(filename), '');  //上传文件

    tmpWeb.Request.ContentType:=FS.RequestContentType;
    url:='';
    return:=tmpWeb.Post(url,FS); //tmpWeb.get(url,FS);
    if return='1' then
    begin
      showmessage('上传成功!');
    end;
  finally
      tmpWeb.Disconnect;
      FreeAndNil(tmpWeb);
      FS.Free;   
  end;

end;

 

 

 

posted @ 2009-11-03 11:54  azhai  阅读(589)  评论(0编辑  收藏  举报