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
Delphi.Narium

Registriert seit: 27. Nov 2017
2.558 Beiträge
 
Delphi 7 Professional
 
#1

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

  Alt 5. Aug 2018, 16:40
Im Objektinspektor kann man doch die Filter beim entsprechenden Attribut erfassen.

Da gibt es (zumindest bei Delphi 7) 'ne Eingabemaske, in der man links den Namen und rechts die Dateiendung(en) angibt.
Das hat den Vorteil, man erfasst die Filter in der korrekten Syntax. Und die wäre da
Delphi-Quellcode:
Filter := 'Delphi-Files (*.pas;*.dpr;*.dpk;*.inc)|*.pas;*.dpr;*.dpk;*.inc';
// oder aber auch
Filter := 'Delphi-Files|*.pas;*.dpr;*.dpk;*.inc';
// oder für HTML
Filter := 'html files|*.htm;*.html|all files|*.*';
// oder eher alles fürs Web
Filter := 'html files|*.htm;*.html|image files|*.bmp;*.gif;*.jpg;*.jpeg;*.png|text files|*.txt|all files|*.*';
Eventuell könnte es ja so funktionieren:
Delphi-Quellcode:
procedure TForm1.Button20Click(Sender: TObject);
var
  Datei: String;
begin
  OpenDialog1.Filter := 'Datei|*.ipk|ZIP-Dateien|*.zip';
  OpenDialog1.FilterIndex := 0;
  if OpenDialog1.Execute then
  begin
    Datei := OpenDialog1.FileName;
    idFTP1.Put(OpenDialog1.FileName,'/tmp/' + ExtractFileName(OpenDialog1.FileName), True);
   end
   else
     ShowMessage('nix ausgewählt...');
end;
Beispiele für Put: https://www.experts-exchange.com/que...ing-files.html

Hier insbesondere den letzten Beitrag lesen: https://www.tek-tips.com/viewthread.cfm?qid=1439325
  Mit Zitat antworten Zitat
Benutzerbild von KodeZwerg
KodeZwerg

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

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


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 06:22 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