Page 1 of 1
Download files from FTP
Posted: Tue Mar 26, 2013 4:43 am
by zolysoftsolutions
Hi all,
I just searched the forum by keyword "FTP" and returns no issues found. Is possible in HMG 3.1.1 to download files from FTP?
Thank you in advance.
Best regards,
Zoli B.
[u]Moderator Notes[/u] (Pablo César) wrote:This topic was moved from HMG Wishlist.
Re: Download files from FTP
Posted: Tue Mar 26, 2013 5:19 am
by Pablo César
zolysoftsolutions wrote:I just searched the forum by keyword "FTP" and returns no issues found.
This most probably is an forum system limitation (in php) for searching strings.
Is possible in HMG 3.1.1 to download files from FTP?
Yes, sure !
There is an example in:
C:\MiniGUI\SAMPLES\Advanced\FtpClient\demo.prg
But there is a faster protocol than ftp, test with http, you can see my example in this brazilian forum:
https://www.pctoledo.com.br/forum/fileba ... t=c&page=1 and another from colleague Marek here:
https://hmgforum.com/viewtopic.php?p=3924#p3924
Re: Download files from FTP
Posted: Tue Mar 26, 2013 6:39 am
by zolysoftsolutions
Thank you very much Pablo.
I was not attent enough. It was near my eyes and I don't see the solution. : )
Thank you again.
Best regards,
Zoli B.
Re: Download files from FTP
Posted: Tue Mar 26, 2013 7:03 am
by mol
Code: Select all
PROCEDURE DownloadFromWWW
param cURL, cLocalFileName, lSilent
LOCAL oCon, oUrl, i, cResponse
local ret := .f.
local oErrorHandler
oErrorHandler := ErrorBlock({|e| break(e)})
BEGIN SEQUENCE
cLocalFileName := alltrim(cLocalFileName)
if lSilent = NIL
lSilent := .f.
endif
oUrl := tURL():New( cUrl )
IF Empty( oUrl )
if !lSilent
MsgBox('Wrong url address: ' + cUrl)
endif
BREAK
ENDIF
IF oUrl:cProto != "http"
if !lSilent
MsgBox('Wrong http address')
endif
BREAK
END
oCon := TipClientHttp():New( oUrl )
oCon:nConnTimeout := 20000
if !lSilent
MsgBox("Connecting with "+ oUrl:cServer)
endif
IF oCon:Open( cUrl )
if !lSilent
MsgBox("Connectio established." +chr(10)+"Press OK to download " + oUrl:cPath +oUrl:cFile)
endif
oCon:WriteAll(cLocalFileName)
if !lSilent
MsgBox("Downloaded and saved as: "+cLocalFileName)
endif
oCon:Close()
ret := .t.
ELSE
IF oCon:SocketCon == NIL
cResponse := "Connection not initialised"
ELSEIF hb_InetErrorCode( oCon:SocketCon ) == 0
cResponse := oCon:cReply
ELSE
if !lSilent
cResponse := "Error in connection: " + hb_InetErrorDesc( oCon:SocketCon )
endif
ENDIF
if !lSilent
MsgBox("I can't connect: "+ oUrl:cServer+chr(10)+"Server answer: "+cResponse)
endif
ret := .f.
END
RECOVER
if !lSilent
MSGSTOP("Error in connectio with server!"+chr(10)+"try to download manually")
endif
END SEQUENCE
ErrorBlock(oErrorHandler)
RETURN ret
Re: Download files from FTP
Posted: Tue Mar 26, 2013 8:10 am
by zolysoftsolutions
Thank you very much Marek,
Is very usefoull procedure, but I have to downoad trough FTP. I just downloaded HMG 3.1.1, but
I haven't Advanced folder in Samples. I need the FTPClient sample.
I found the sample.. in Minigui : )
Regards,
Zoli B.
Re: Download files from FTP
Posted: Tue Mar 26, 2013 8:47 am
by mol
try do download harbour nightly sources and you'll find all samples there.
I'm attaching contrib\hbtip folder from harbour
Re: Download files from FTP
Posted: Tue Oct 08, 2013 5:33 am
by sudip
Great! Thanks a lot
