Thursday, June 21, 2007

HTTP Post

Webbase application is good for any operation system,however, it's not simple to make it easy for bulk data manipulation. While, desktop application has it, easy for bulk data manipulation, user friendly and etc.
Why? Because desktop application, delphi for example, supported event driven, while webbase is not.
Now many webbase language, like php, combined with ajax can handle this, however, it's need huge of memory resources.

In order to solve this obstacle, delphi has already prepared. With IdHTTP (Indy component), we can manipulate web application through dekstop application.

The following is an example:

procedure TFHttpUpload.Upload;
var
Stream : TIdMultipartFormDataStream;
begin
Stream := TIdMultipartFormDataStream.Create;
try
StatusBar1.SimpleText:='Upload............';
Stream.AddFormField('ffield1','one');
Stream.AddFormField('ffield2','dua');
Stream.AddFile( 'fFile', fname, 'text/plain' );
str :=IdHTTP1.Post('http://www.myweb.com/upload.php', Stream );
ShowMessage('Upload Sucess :)');
except
ShowMessage('Upload Fail :(');
end;
Stream.Free;
end;