Autor Beitrag
ralfi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 153



BeitragVerfasst: Mi 02.06.04 18:27 
Hallo!

Ich lade auf den Server eine Datei hoch:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
...
var 
PicData: TIdMultiPartFormDataStream; 

PicData := TIdMultiPartFormDataStream.Create; 
PicData.AddFile('file''C:\Datei.exe''application/zip'); 
IdHTTP1.Post('http://www.homepage.de/cgi-bin/loadPicture.pl?', PicData);
...


Ich möchte dem User auch zeigen, wie weit der Uploadprocess ist. Beim download ist klar:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
...
procedure TForm1.IdHTTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer);
begin
ProgressBar1.Max := AWorkCountMax;
application.ProcessMessages;
end;
...


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
...
procedure TForm1.IdHTTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer);
begin
Label1.Caption := IntToStr(AWorkCount div 1024) + ' Kb von ' + 
IntToStr(http.Response.ContentStream.Size div 1024) + ' Kb';
ProgressBar1.Position := AWorkCount;
application.ProcessMessages;
end;
...


Kann ich diese Code irgendwie modernisieren, sodass der Upload-Fortschritt angezeigt wird?

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Mi 02.06.04 20:16 
also mit der routine wird doch auch ein upload in der progressbar angezeigt !! bei mir jedenfalls

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Kugelblitz
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 34

Win XP, Debian

BeitragVerfasst: Do 22.03.07 21:56 
auch auf die gefahr hin dass ich jetzt ein total altes thema unnütz wieder anspreche: ^^

Ich hab das gleiche problem
die progressbar läuft zwar durch, aber dass ich eine 5 MB datei in 5 sekunden uploade kann wohl nicht sein ;)
außerdem dauert das uploaden (biss ich von der seite auch eine reply bekomme) deutlich länger

der Code im OnWork und OnWorkBegin ist im prinzip der gleiche, anders ist eigentlich nur dass ich außer der datei noch 3 parameter mit poste..

_________________
I haven't lost my mind; it's backed up on tape somewhere!
Timi-loader
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58

Win XP
Delphi 7 Personal
BeitragVerfasst: Mo 21.05.07 01:27 
bei mir geht das mit dem upload und progressanzeige auch nicht. :-(

kennt jemand ne andere lösung?

vllt doch datei "per hand" streamen?

mfg
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 21.05.07 09:13 
Hast du auch die passenden Ereignisse gesetzt (im OI)?
Timi-loader
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58

Win XP
Delphi 7 Personal
BeitragVerfasst: Mo 21.05.07 22:32 
muss man da noch zusätzlich einen io machen?
also der io hat bei mir dann nur ein onstatus ereignis.

mfg
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 22.05.07 15:29 
user profile iconTimi-loader hat folgendes geschrieben:
muss man da noch zusätzlich einen io machen?
also der io hat bei mir dann nur ein onstatus ereignis.

mfg

Tino meinte, ob Du im Objektinspektor die entsprechenden Ereignisse von IdHttp1 auf die obigen Methoden gesetzt hast. Du brauchst keinen IoStream.
Timi-loader
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58

Win XP
Delphi 7 Personal
BeitragVerfasst: Di 22.05.07 15:42 
achsoo. hab io und oi vertauscht^^ also kla. jo die ereignisse hab ich ja erst angelegt und dann mit dem code gefüllt. (bzw ersetzt)

aber funzen tut das gesamt nicht.. hmm

EDIT: also konkret wird bei mir onwork nur einmal direkt am ende des downloads aufgerufen. aber ich hab die nicht verwechselt.


Zuletzt bearbeitet von Timi-loader am Di 22.05.07 16:13, insgesamt 1-mal bearbeitet
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 22.05.07 15:45 
Das ist keine Antwort auf die Frage. Hast du die Ereignisse im OI auch mit der Komponente verknüpft?
k4hvd
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Di 22.05.07 16:23 
ich würde das hier ausprobieren:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.IdHTTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer);
begin
  if AWorkMode = wmWrite then
    begin
     ProgressBar1.Max := AWorkCountMax;
     application.ProcessMessages;
    end;  
end;


procedure TForm1.IdHTTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer);
begin
  if AWorkMode = wmWrite then
    begin 
      Label1.Caption := IntToStr(AWorkCount div 1024) + ' Kb von ' + 
      IntToStr(http.Response.ContentStream.Size div 1024) + ' Kb';
      ProgressBar1.Position := AWorkCount; 
      application.ProcessMessages;
    end;
end;



Gruß
Max
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 22.05.07 16:50 
Was heißt eigentlich:
user profile iconTimi-loader hat folgendes geschrieben:
aber funzen tut das gesamt nicht.. hmm

:roll:
Timi-loader
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58

Win XP
Delphi 7 Personal
BeitragVerfasst: Di 22.05.07 22:32 
also ichb hab mir mal ne zählschleife gebaut und die procedure TForm1.IdHTTP1Work wird bei mir nur einmal am ende ausgeführt. mehr nicht. wieso?

mfg
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 22.05.07 23:29 
user profile iconTimi-loader hat folgendes geschrieben:
also ichb hab mir mal ne zählschleife gebaut und die procedure TForm1.IdHTTP1Work wird bei mir nur einmal am ende ausgeführt. mehr nicht. wieso?

Setz mal ein Application.ProcessMessages in das OnWork-Ereignis.

Wie groß ist denn die Datei, die du hochlädst?
Timi-loader
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 58

Win XP
Delphi 7 Personal
BeitragVerfasst: Mi 23.05.07 11:16 
processmessageges hab ich bereits drinn. die datei mit der ich teste ist ca 900 kb groß. und trotz der eventuellen anzeigeprobleme würde ja in der theorie die zählschleuife auch höher geben. aber das tut sie nur ein mal.

mfg
LexXis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 170
Erhaltene Danke: 3



BeitragVerfasst: Do 07.06.07 16:23 
Ich hatte den Spaß mal beim Download.
Aus irgendeinem Grund wurde da AWorkCoutMax nicht richtig gesetzt.
Hab das dann elegant umgangen indem ich als Maximum meiner Progressbar
die Größe das Streams, den ich hoch/runterladen wollte als Max angegeben hab.
Mag nicht unbedingt korrekt sein, bei mir hat´s aber funktioniert.

mfg lexxis
agent_x
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: So 23.09.07 09:13 
Hallo,
bei mir geht das nicht:
ausblenden Delphi-Quelltext
1:
2:
Label1.Caption := IntToStr(AWorkCount div 1024) + ' Kb von ' + 
      IntToStr(http.Response.ContentStream.Size div 1024) + ' Kb';

HELP!!!
MfG agent_x
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: So 23.09.07 10:07 
user profile iconagent_x hat folgendes geschrieben:
bei mir geht das nicht:

Könntest du das Problem bitte genauer beschreiben.
agent_x
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: So 23.09.07 13:55 
ja bei mir wird im script http und das hinter den kommas rot
unterkritzelt