Hi. all !
Is it possible to download a file from a URL (not via FTP)
FUNCTION GETURLTOFILE( cUrl, cFile, cUsr, cPsw )
LOCAL lOk := .F.
LOCAL oHtp, oStr
DEFAULT cFile := FILENAME( STRTRAN( cUrl, "/", "\" ) )
TRY
oHtp = CREATEOBJECT( "MSXML2.XMLHTTP" )
oHtp:Open( "POST", cUrl, .F., cUsr, cPsw )
oHtp:Send()
IF oHtp:Status != 200 THEN BREAK
oStr = CREATEOBJECT( "ADODB.Stream" )
oStr:Open()
oStr:Type = 1
oStr:Write( oHtp:ResponseBody )
oStr:SaveToFile( cFile, 2 )
oStr:Close()
lOk = .T.
CATCH
END
RETURN lOk
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 76 guests