HTTP-POST Delphi 7

Have a little trivial problem, but on my zero level knowledge about this issue would ask experts...
I have to sent textfile to web-robot with HTTP-POST function.

Form code would be as follow:

<form ENCTYPE="multipart/form-data"
action="http://contest.sk6aw.net/contest/robot/?automatic=true"
method="POST"
<input type="text" name="contest_type">
<input type="text" name="contest_date">
<input type="text" file="logfile">
</form>

Can't found any TIdMultipartFormDataStream on my old Indy (Delphi 7).
Have tried with Synapse but have several problems to set parameters!
How to do? Thanks in advance.
ejla51Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lomo74Commented:
try the following:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdMultipartFormData, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, IdHTTP, StdCtrls;

type
  TForm1 = class(TForm)
    IdHTTP1: TIdHTTP;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  strm: TIdMultiPartFormDataStream;
begin
  strm := TIdMultiPartFormDataStream.Create;
  try
    strm.AddFormField('contest_type', 'value1');
    strm.AddFormField('contest_date', 'value2');
    strm.AddFile('logfile', 'C:\logfile.txt', 'text/plain');
    IdHTTP1.Post('http://contest.sk6aw.net/contest/robot/?automatic=true', strm);
  finally
    strm.Free;
  end;
end;

end.

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ejla51Author Commented:
Thanks for all tips!
I have some problems with Indy & Avira antivirus... Avira will indicade Troijan in my compiled program! I have to check this issue if my Indy is infected or if this detection is false-true,
0
lomo74Commented:
be aware that Avira is known to detect many false positives.

>> I have to check this issue if my Indy is infected
it would be quite unusual for a virus program to infect the Indy .dcu files you're using to build your exe, right?
viruses infect almost anything, including mac batteries (http://matsucomputermedics.com/index.php/forum/Everything-Else/102-Apple-MacBook-Batteries-Vulnerable-to-Virus-that-can-make-them-Explode), but I never heard of a virus injecting itself into .dcu files...

I had many problems with Avira and Indy-based applications in the past, that's why I moved to Avast (for free protection) and to NOD32 (for paying users).
anyway, feel free to carry out your tests, but IMHO you're wasting your time :)
0
ejla51Author Commented:
Thanks Sirs for advices...
Everything works fine now...
sinisav: Yes, of course I had forget to add  "IdMultipartFormData" to uses...
lomo74: Your code snippet works directly - very good lesson for me (have not any Indy helpfiles).

I think I have to share Points... Thanks again!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.