As I've said in other post, I'm working on an Internet project (a database application/website) and I need FTP access from a client (HMG) application.
Sadly Matteo Baccan socket lib has only basic support for FTP (only login and list). So, I've searched for an alternative and dig (again) on HBTIP.
I've amazed with superb support for FTP. Only in minutes, I've managed to login, create and delete folders and files in an extremely easy way.
Of course... HBTIP is included and linked by default in HMG from some time ago.
This is the one on two FTP console demos bundled with HBTIP (Harbour) source:
Code: Select all
/*
* $Id: ftpadv.prg 8734 2008-06-15 21:11:36Z vszakats $
*/
/******************************************
* TIP test
* FTP Advanced operations Test
*****/
PROCEDURE MAIN( cUrl )
LOCAL oCon, oUrl
oUrl := tURL():New( cUrl )
IF Empty( oUrl )
? "Invalid url " + cUrl
?
QUIT
ENDIF
IF oUrl:cProto != "ftp"
? 'This is a "DELE" test for ftp.'
? 'Use an ftp address with a file that you can delete.'
?
QUIT
END
oCon := TipClientFtp():New( oUrl )
oCon:nConnTimeout := 20000
? "Connecting with", oUrl:cServer
IF oCon:Open( cUrl )
? "Connection eshtablished"
? "Deleting", oUrl:cPath
IF oCon:CWD( oUrl:cPath )
? "CWD success"
IF oCon:Dele( oUrl:cFile )
? "DELE success"
ELSE
? "DELE Faliure (server reply:", oCon:cReply + ")"
ENDIF
ELSE
? "CWD Faliure (server reply:", oCon:cReply + ")"
ENDIF
oCon:Close()
ELSE
? "Can't connect with", oUrl:cServer
IF oCon:SocketCon == NIL
? "Connection not initiated"
ELSEIF hb_InetErrorCode( oCon:SocketCon ) == 0
? "Server sayed:", oCon:cReply
ELSE
? "Error in connection:", hb_InetErrorDesc( oCon:SocketCon )
ENDIF
END
? "Done"
?
RETURN
Code: Select all
ftp://user:passwd@<ftpserver>/[<path>]
Regards,
Roberto.