Autor Beitrag
Killi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 299

Win*
D6 Prof
BeitragVerfasst: Do 07.08.03 10:31 
Hi!

Wie kann ich per FTP einfach und schnell in meinem Delphi-Prog auf unseren Server was hochschieben?
Ak-Alex
Gast
Erhaltene Danke: 1



BeitragVerfasst: Do 07.08.03 12:19 
bei den indy komponenten und fastnet sind demos bei...schau da mal
The-FoX
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 203

Win XP
D6 Pers
BeitragVerfasst: So 10.08.03 03:59 
Du machst die Indykomponente idftp in die form. Gisbst dann username, pw und host ein. Dann kommt der code:
ausblenden Delphi-Quelltext
1:
2:
3:
idftp1.connect;
idftp1.put ('1' , '2'3); // 1 ist das verzeichniss lokal (also zb. c:\hans.txt) 2 ist der Zielname (Also z.B. Hans.txt) 3 gibt an ob überschrieben werden darf (wenn ja: true)
idftp1.disconnect;
Killi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 299

Win*
D6 Prof
BeitragVerfasst: Di 12.08.03 11:20 
wo krieg ich idftp denn her? Hab schon bei Torry gesucht, nix gefunden...

---

ok, ok - bei Delphi 6 dabei...!
Hab den Code hier:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Button1Click(Sender: TObject);
begin
idftp1.connect;
idftp1.put ('C:\wurst.txt' , 'mainwebsite_html/wurst.txt', True); // 1 ist das verzeichniss lokal (also zb. c:\hans.txt) 2 ist der Zielname (Also z.B. Hans.txt) 3 gibt an ob überschrieben werden darf (wenn ja: true)
idftp1.disconnect;
end;

Aber er macht irgendwie nix...stimmt mein Zielordner nicht? gehört ein "/" davor? Wie merke ich dass er was macht?

---

Hä? Mit ChangeDir vor dem put gehts....kam allerdings auch kurz n Fehler - naja, THX!!!!!!!

Moderiert von user profile iconTino: Beiträge zusammen geführt.
The-FoX
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 203

Win XP
D6 Pers
BeitragVerfasst: Di 19.08.03 00:53 
1.) Kommt eine Fehlermeldung? Wenn ja:
Geh mal auf Seite 2 im Internet/netzwerk Forum, da steht ein Thread mit dem Namen "Problem mit Datei hochladen [gelöst]" Der Thread is von mir, und ich hab in ihm die Lösung zu deinem Problem gepostet.

2.) Jo du darfst keine solchen Namen angeben: /xxx/xxx. Musst davor also Changedir ('mainwebsite_html') machen.
oPPi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 66

MS Win 7 Pro, WinXP Pro
D3 Pro, TurboDelhi, Kylix 3 Pro
BeitragVerfasst: Do 21.08.03 22:04 
Probiers mal mit dem nachfolgenden Code, bei mir klappt das einwandfrei.

Beachte: Bei Strato ist User gleich Host

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
begin
  try
    idFTP1.Host := txt_Host.Text;   
    idFTP1.User := txt_UserID.Text;
    idFTP1.Port := 21;
    idFTP1.Password := txt_Password.Text;
    idFTP1.Connect(true);
    idFTP1.ChangeDir('test');
    idFTP1.Put('test.txt''test.txt', true);
    ShowMessage('Die Datei test.txt wurde hochgeladen!!!');
  except
      ShowMessage('Die Datei test.txt konnte nicht hochgeladen werden!!!');
  end;
hibbert
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Fr 22.08.03 16:24 
Sorry, wenn ich mich da mal einmische, aber ich habe das mal ausprobiert (beide Versionen).
Die .txt wird zwar auf meinen Server geladen, sie ist aber 0 kb groß und halt keinen Inhalt. (bei beiden Möglichkeiten)

Kann ich die Datei auch mit Inhalt auf meinen Server laden?

hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
oPPi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 66

MS Win 7 Pro, WinXP Pro
D3 Pro, TurboDelhi, Kylix 3 Pro
BeitragVerfasst: Sa 23.08.03 08:31 
hy,

ich hatte das mit der test.txt auch nur als beispiel angegeben.

ich hab das jetzt mal mit ner filelistbox + Editfeld + Memofeld +
IndyFTP + Statusbar probiert:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
...

var
  Form1: TForm1;
  str1, str2 : TStringList;
  strings, path : String;

implementation

{$R *.dfm}

procedure TForm1.FileListBox1Click(Sender: TObject);
begin
  str1 := TStringList.Create;
  str1.LoadFromFile(FileListBox1.Items.Strings[FileListBox1.ItemIndex]);
  strings := str1.Text;
  str1.Free;
  Memo1.Text := strings;
  txt_Datei.Text := FileListBox1.Items.Strings[FileListBox1.ItemIndex];
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  try
    idFTP1.Host := txt_Host.Text;
    idFTP1.User := txt_UserID.Text; 
    idFTP1.Port := 21;
    idFTP1.Password := txt_Password.Text; 
    idFTP1.Connect(true); 
    idFTP1.ChangeDir('daten');
    idFTP1.Put(txt_Datei.Text, txt_Datei.Text, true);
    StatusBar1.SimpleText := 'Die Datei ' + txt_Datei.Text + ' wurde hochgeladen !!!';
    idFTP1.Disconnect;   
  except 
      StatusBar1.SimpleText := 'Die Datei ' + txt_Datei.Text + ' konnte nicht hochgeladen werden !!!';
  end;
end;


das müsste eigentlich jetzt mit jeder x-beliebigen Datei funktionieren.

gruß

oPPi


Zuletzt bearbeitet von oPPi am Sa 23.08.03 18:10, insgesamt 1-mal bearbeitet
thebe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128

WinXP Home
D6 Enterprise
BeitragVerfasst: Sa 23.08.03 17:01 
Da is nach dem put kein disconnect nur ma so BTW
hibbert
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Sa 23.08.03 18:28 
hmm,
ist ja schön und gut, doch was nüzt es einem, wenn die Datei hochgeladen wird, diese aber keinen inhalt hat? Bei mir werden immer nur leere .txt dateien hochgeladen. So nach 2 Minuten habe ich dann doch aufgegeben.

Da funzt doch was nicht, oder?

Hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
oPPi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 66

MS Win 7 Pro, WinXP Pro
D3 Pro, TurboDelhi, Kylix 3 Pro
BeitragVerfasst: Sa 23.08.03 20:23 
also bei mir funzt das einwandfrei

1. ich wähle aus der filelistbox ne datei aus
2. nach dem auswählen wird der name der datei
im ensprechenden editfeld angezeigt.
3. wenn ich auf die schaltfläche für das hochladen
klicke wird diese auch voll und ganz (KB's)
hochgeladen.

Ich weiß nicht vielleicht liegt es ja an der Verbindung
ich verfüge über DSL und da klappt das einwandfrei.

@hibbert
wenn du willst kann ich dir mal das beispiel-proggi mit Quellcode
zuschicken, wenns damit auch nicht funzt liegt es wahrscheinlich
an deiner Leitung was nicht :?
hibbert
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: So 24.08.03 17:53 
oPPi hat folgendes geschrieben:
@hibbert
wenn du willst kann ich dir mal das beispiel-proggi mit Quellcode
zuschicken, wenns damit auch nicht funzt liegt es wahrscheinlich
an deiner Leitung was nicht :?


Also auch ich habe DSL und es wäre nett, wenn du mir mal ein beispiel schicken könntest. am besten per e-mail (s.u.). Ich weiß auch net warum das net funzt.

thx hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
oPPi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 66

MS Win 7 Pro, WinXP Pro
D3 Pro, TurboDelhi, Kylix 3 Pro
BeitragVerfasst: Mo 25.08.03 20:20 
also für alle die das beispiel haben wollen:
Link: Beispiel