AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Lazarus (IDE) mit opendialog file auswählen und zum ftp senden?
Thema durchsuchen
Ansicht
Themen-Optionen

mit opendialog file auswählen und zum ftp senden?

Ein Thema von Reiter0303 · begonnen am 5. Aug 2018 · letzter Beitrag vom 5. Aug 2018
Antwort Antwort
Seite 2 von 2     12   
Benutzerbild von KodeZwerg
KodeZwerg

Registriert seit: 1. Feb 2018
3.685 Beiträge
 
Delphi 11 Alexandria
 
#11

AW: mit opendialog file auswählen und zum ftp senden?

  Alt 5. Aug 2018, 17:37
Meine Delphi-Hilfe spuckt fürs Thema FTP auch ein paar interessante Dinge aus, hier ein Beispiel um eine Datei hochzuladen.
Zitat:
Placing Files on an FTP Server

There are two methods for placing a file on an FTP server:


Use FtpOpenFile with InternetWriteFile.
Use FtpPutFile.
An application that must send data to an FTP server, but does not have a local file that contains all the data, should use FtpOpenFile to create and open a file on the ftp server. The application then can use InternetWriteFile to upload the information to the file.

If the file already exists locally, the application can use FtpPutFile to upload the file to the FTP server. FtpPutFile performs all the overhead that goes with uploading a local file to a remote FTP server.

The following example copies a local file onto the FTP server. The local name of the file is taken from the edit box in the parent dialog whose IDC is passed in the nLocalFileNameId parameter, and the name under which the file is saved on the FTP server is taken from the edit box whose IDC is passed in the nFtpFileNameId parameter. The hConnection handle was created by InternetConnect after establishing an FTP session.
Code:
BOOL WINAPI PutFtpFile( HWND hDlg, HINTERNET hConnection,
                        int nFtpFileNameId, int nLocalFileNameId )
{
  TCHAR szFtpFileName[FTP_FUNCTIONS_BUFFER_SIZE];
  TCHAR szLocalFileName[FTP_FUNCTIONS_BUFFER_SIZE];
  DWORD dwTransferType;
  TCHAR szBoxTitle[] = TEXT( "Upload FTP File" );
  TCHAR szASCIIQuery[] =
    TEXT("Do you want to upload as ASCII text? (Default is binary)");
  TCHAR szAsciiDone[] =
    TEXT( "ASCII Transfer completed successfully..." );
  TCHAR szBinaryDone[] =
    TEXT( "Binary Transfer completed successfully..." );

  if( !GetDlgItemText( hDlg, nFtpFileNameId, szFtpFileName,
                       FTP_FUNCTIONS_BUFFER_SIZE ) ||
      !GetDlgItemText( hDlg, nLocalFileNameId, szLocalFileName,
                       FTP_FUNCTIONS_BUFFER_SIZE ) )
  {
    MessageBox( hDlg,
                TEXT("Target File or Destination File Missing"),
                szBoxTitle,
                MB_OK | MB_ICONERROR );
    return( FALSE );
  }

  dwTransferType =
    ( MessageBox( hDlg,
                  szASCIIQuery,
                  szBoxTitle,
                  MB_YESNO ) == IDYES ) ?
    FTP_TRANSFER_TYPE_ASCII : FTP_TRANSFER_TYPE_BINARY;

  if( !FtpPutFile( hConnection,
                   szLocalFileName,
                   szFtpFileName,
                   dwTransferType,
                   0 ) )
  {
    InternetErrorOut( hDlg, GetLastError( ), TEXT( "FtpGetFile" ) );
    return( FALSE );
  }

  MessageBox( hDlg,
              ( dwTransferType == FTP_TRANSFER_TYPE_ASCII ) ?
                szAsciiDone : szBinaryDone, szBoxTitle, MB_OK );
  return( TRUE ); // Remember to refresh directory listing
}
Gruß vom KodeZwerg
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 2 von 2     12   


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:22 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz