idHTTP upload a zip file with POST method

Giganews Newsgroups
Subject: idHTTP upload a zip file with POST method
Posted by:  Fahd (fahd…@quickpractice.com)
Date: Fri, 16 Jun 2006

If I run this code I get an error message saying "Error encountered during
POST: IOHandler value is not valid -1
I don't know why is giving me -1 because I don't see anything wrong with my
code!!
please help thank you

Fahd

  PostStream := TIdMultiPartFormDataStream.Create;
  ResponseStream := TStringStream.Create('');

  try
    IdHttp1.Request.ContentType := PostStream.RequestContentType;
    PostStream.AddFormField('wsUserID', sUserID);
    PostStream.AddFormField('wsPassword', sPassword);
    PostStream.AddFormField('wsMessageType', sMessageType);
    PostStream.AddFile('wsPutFile', path, 'multipart/form-data');
    with IdHTTP1 do begin
      try
        Request.ContentType := PostStream.RequestContentType;
        post(sURL, PostStream, ResponseStream);
      except
      on E: Exception do
          showmessage('Error encountered during POST: ' + E.Message+ ': '
+intToStr(IdHTTP1.Response.ResponseCode));
      end;
    end;
  finally
    Memo1.Lines.Text :=ResponseStream.DataString;
    PostStream.Free;
    ResponseStream.Free;
  end;

Replies