Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi FTP, Datei in Ordner schreiben (https://www.delphipraxis.net/83350-ftp-datei-ordner-schreiben.html)

wurst_hunter 31. Dez 2006 16:01


FTP, Datei in Ordner schreiben
 
Okay... Irgendwie bekomm ich es nicht hin, eine Datei in einen Ordner auf meinem FTP-Server upzuloaden!

So sieht die Funktion aus

Delphi-Quellcode:
function UploadFolder(lpszServer, lpszUsername, lpszPassword, lpszLocalDirectory, lpszRemoteDirectory: String; wPort: Word = 21): Boolean;
var
  hOpen, hConnect: HINTERNET;
begin
  Result := False;
  hOpen := InternetOpen('MyAgent', INTERNET_OPEN_TYPE_DIRECT, nil, nil, 0);
  if (hOpen <> nil) then
  begin
    hConnect := InternetConnect(hOpen, PChar(lpszServer), wPort, PChar(lpszUsername), PChar(lpszPassword),
                                INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);

   Result := FtpPutFile(hconnect, pchar(lpszLocalDirectory),
    pchar('/html/small/test.jpg'), //<-- test.jpg soll in den Ordner small, klappt aber nicht!
      FTP_TRANSFER_TYPE_UNKNOWN, 0);
   InternetCloseHandle(hConnect);
   InternetCloseHandle(hOpen);
  end
end;
Warum? Ahhh! :wall:

Daniel G 31. Dez 2006 16:11

Re: FTP, Datei in Ordner schreiben
 
Zitat:

Zitat von wurst_hunter
Warum? Ahhh! :wall:

Weil das
Delphi-Quellcode:
Result := FtpPutFile(hconnect, pchar(lpszLocalDirectory),
    pchar('/html/small/test.jpg'), //&lt;-- test.jpg soll in den Ordner small, klappt aber nicht!
      FTP_TRANSFER_TYPE_UNKNOWN, 0);
so nicht funktioniert. Du musst erst mit

Delphi-Quellcode:
FtpSetCurrentDirectory(hConnect, pchar('/html/small'));
in das Verzeichnis wechseln.

Und dann lauten die Parameter für die Funktion FtpPutFile:

Delphi-Quellcode:
Result := FtpPutFile(hconnect, pchar(lpszLocalDirectory),
    pchar('test.jpg'), FTP_TRANSFER_TYPE_BINARY, 0);
Gruß,
Daniel


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:49 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz