unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, idmultipartformdata, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdHTTP, Psock, NMHttp, IdAntiFreezeBase,
IdAntiFreeze, ComCtrls, Menus;
type
TForm1 =
class(TForm)
Button1: TButton;
IdHTTP1: TIdHTTP;
Memo1: TMemo;
Button2: TButton;
ListBox1: TListBox;
OpenDialog1: TOpenDialog;
NMHTTP1: TNMHTTP;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
Button3: TButton;
IdAntiFreeze1: TIdAntiFreeze;
GroupBox3: TGroupBox;
ProgressBar1: TProgressBar;
StatusBar1: TStatusBar;
PopupMenu1: TPopupMenu;
Deletefilefromlist1: TMenuItem;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Deletefilefromlist1Click(Sender: TObject);
procedure Idhttp1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
procedure Idhttp1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
private
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Stream: TIdMultiPartFormDataStream;
StringStream: TStringStream;
begin
Stream := TIdMultiPartFormDataStream.Create;
StringStream := TStringStream.Create('
');
try
Stream.AddFile('
file',listbox1.Items[0], '
multipart/form-data');
IdHTTP1.Post('
http://filecoastcom.h1072562.serverkompetenz.net/submit.php', Stream, StringStream);
Memo1.Text := StringStream.DataString;
finally
Stream.Free;
StringStream.Free;
end;
end;
// ########## Statusbalken ############ //
procedure TForm1.Idhttp1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
begin
ProgressBar1.Max := AWorkCountMax;
ProgressBar1.Position := 0;
end;
procedure TForm1.Idhttp1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
Var
S:
String;
TotalTime: TDateTime;
H, M, Sec, MS: Word;
DLTime: Double;
STime: TDateTime;
AverageSpeed: Double;
begin
Application.ProcessMessages;
//Errechnen der Transfergeschwindigkeit:
TotalTime := Now - STime;
DecodeTime(TotalTime, H, M, Sec, MS);
Sec := Sec + M * 60 + H * 3600;
DLTime := Sec + MS / 1000;
if DLTime > 0
then
AverageSpeed := (AWorkCount / 1024) / DLTime;
S := FormatFloat('
0.00 KB/s', AverageSpeed);
case AWorkMode
of
wmWrite :StatusBar1.Panels[1].Text := '
Uploade speed ' + S;
end;
//Aktualisieren der Fortschrittsanzeige:
ProgressBar1.Position := AWorkCount;
Form1.ProgressBar1.Refresh;
end;
// ########## ENDE ############ //
procedure TForm1.Button2Click(Sender: TObject);
var
anzahl_listbox: integer;
begin
opendialog1.Execute;
anzahl_listbox := listbox1.Items.Count;
listbox1.Items[anzahl_listbox] := opendialog1.FileName;
anzahl_listbox := listbox1.Items.Count;
NMHTTP1.Get('
http://www.filecoast.com/uploadtool/uploadtool_serverwahl.php');
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
listbox1.DeleteSelected;
end;
procedure TForm1.Deletefilefromlist1Click(Sender: TObject);
begin
listbox1.DeleteSelected;
end;
end.