I am looking to update my interface for FTP uploads and downloads. I need to do the following:
- Upload a file
Download a file
See what files are available on the server
Delete a file on the server after downloading
Thanks for your suggestions.
Code: Select all | Expand
function download()
local oInternet := TInternet():New()
local oFTP := TFTP():New( "192.168.0.230", oInternet,"remanco", "pwremanco" )
local aFiles
local handle
*----------------------------------------------------------
if ! Empty( oFTP:hFTP )
FtpSetCurrentDirectory(oFTP:hFTP, "/usr/cheshire/boh/")
aFiles = oFTP:Directory("rms.dat" )
IF len(aFiles) > 0
AEval( aFiles, { | aFile | FtpGetFile ( oFTP:hFTP, aFile[ 1 ], "c:\remanco\" + aFile[ 1 ] ,.t.,0,0,0 ) } )
ENDIF
else
// MsgAlert( "oFTP:hFTP is null" )
endif
oInternet:End()
return nil
function f_senden( cDatei )
local oInternet := TInternet():New()
local oFTP := TFTP():New( "ftp.test.info", oInternet, "salettainfo", "pwsaletta" )
local aInfo := {}
local I := 0
local cAktivInfoDir := Setup():AppPath + "report" //Setup():Daten() + "\xReport"
*----------------------------------------------------------
if Empty( oFTP:hFTP )
MsgStop( "Cannot connect to the specified FTP site!" )
return nil
endif
if ! Empty( oFTP:hFTP )
select EMPFAREP
do while .not. eof()
if FTPPUTFILE( oFTP:hFTP, cAktivInfoDir + "\"+ cDatei, "/salettainfo/AktivInfo/1" + Alltrim(EMPFAREP->email) , 0, 0 ) = .t.
else
msginfo("konnte nicht gesendet werden: " + cAktivInfoDir + "\" + cDatei + CRLF +;
"/salettainfo/AktivInfo/" + cDatei )
endif
select EMPFAREP
skip
enddo
else
MsgAlert( "oFTP:hFTP is null" )
endif
ferase ( cAktivInfoDir + "\" + cDatei)
oInternet:End()
logfile( "aktivInfo.log", { "nach senden ", } )
return nil
//----------------------------------------------------------------------------//
Code: Select all | Expand
FtpSetCurrentDirectory(oFTP:hFTP, "/meldemax")
aFiles = oFTP:Directory("*.*" )
xbrowse(aFiles)
IF len(aFiles) > 0
AEval( aFiles, { | aFile | msginfo( aFile[ 1 ] ),cFile := ALLTRIM( aFile[ 1 ] ),;
cFile := STRTRAN(UPPER(cFile),".TXT",".LTX"),;
FtpGetFile (oFTP:hFTP,aFile[ 1 ], "c:\dbf\" + aFile[ 1 ] ,.t.,0,0,0 ) ,;
oFTP:DeleteFile( aFile[ 1 ]),;
endif
Otto wrote: Sat Mar 04, 2023 2:16 am Hello Tim,
I am working on the same problem right now.
FTP should be replaced with secure FTP.
I don't have an example here yet.
For FTP I use the following function.
I wanted to change now unlike you to cURL: https:// and send with cURL.
curl --cacert /path/to/cacert.pem https://example.com
But I get this error: SSL certificate verify result: unable to get local issuer certificate (20)
Do you send with cURL and https?
Best regards,
Otto
Code: Select all | Expand
function download() local oInternet := TInternet():New() local oFTP := TFTP():New( "192.168.0.230", oInternet,"remanco", "pwremanco" ) local aFiles local handle *---------------------------------------------------------- if ! Empty( oFTP:hFTP ) FtpSetCurrentDirectory(oFTP:hFTP, "/usr/cheshire/boh/") aFiles = oFTP:Directory("rms.dat" ) IF len(aFiles) > 0 AEval( aFiles, { | aFile | FtpGetFile ( oFTP:hFTP, aFile[ 1 ], "c:\remanco\" + aFile[ 1 ] ,.t.,0,0,0 ) } ) ENDIF else // MsgAlert( "oFTP:hFTP is null" ) endif oInternet:End() return nil function f_senden( cDatei ) local oInternet := TInternet():New() local oFTP := TFTP():New( "ftp.test.info", oInternet, "salettainfo", "pwsaletta" ) local aInfo := {} local I := 0 local cAktivInfoDir := Setup():AppPath + "report" //Setup():Daten() + "\xReport" *---------------------------------------------------------- if Empty( oFTP:hFTP ) MsgStop( "Cannot connect to the specified FTP site!" ) return nil endif if ! Empty( oFTP:hFTP ) select EMPFAREP do while .not. eof() if FTPPUTFILE( oFTP:hFTP, cAktivInfoDir + "\"+ cDatei, "/salettainfo/AktivInfo/1" + Alltrim(EMPFAREP->email) , 0, 0 ) = .t. else msginfo("konnte nicht gesendet werden: " + cAktivInfoDir + "\" + cDatei + CRLF +; "/salettainfo/AktivInfo/" + cDatei ) endif select EMPFAREP skip enddo else MsgAlert( "oFTP:hFTP is null" ) endif ferase ( cAktivInfoDir + "\" + cDatei) oInternet:End() logfile( "aktivInfo.log", { "nach senden ", } ) return nil //----------------------------------------------------------------------------//