ftp upload/download

ftp upload/download

Postby damianodec » Mon Feb 07, 2022 3:23 pm

Hi,
any example of ftp upload/download ?

thank you
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
 
Posts: 419
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: ftp upload/download

Postby cmsoft » Mon Feb 07, 2022 9:39 pm

Code: Select all  Expand view  RUN

***************************************
** Descargar archivo desde la web
function Descargar(cUrl,cDestino)
LOCAL nRet
DELETEURLCACHEENTRY(  cUrl )
nRet := DOWNLOADFILE( cUrl, cDestino)
RETURN nRet = 0


#pragma BEGINDUMP
#include <Windows.h>
#include <hbapi.h>
#include <urlmon.h>
HB_FUNC( DOWNLOADFILE )
{
        HRESULT hr;      
        hr = URLDownloadToFile( NULL, hb_parc( 1 ), hb_parc( 2 ), 0, NULL ) ;
        hb_retnl( hr ) ;
}
#pragma ENDDUMP

DLL STATIC FUNCTION DELETEURLCACHEENTRY( cUrl AS LPSTR ) AS BOOL;
PASCAL FROM "DeleteUrlCacheEntryA" LIB "wininet.dll"

*****************************************
*** Conectar al servidor FTP
FUNCTION ConectaServerFTP(cNomSer,cNomUsr,cClaUsr,oFtp) //oFtp pasar por referencia
LOCAL cServer, cUser, cPassword, oUrl, cUrl
cServer := cNomSer
cUser := cNomUsr
cPassword := cClaUsr
cUrl := "ftp://" + cUser + ":" + cPassword + "@" + cServer
cUser:= strtran(cUser,"@","&at;")
oUrl := tUrl():New( cUrl )
IF At( "@", cUser ) > 0
   oUrl:cUserID := strtran(cUser,"&at;","@")
   oUrl:cPassword := cPassword
ENDIF
oFTP := tIPClientFtp():New( oUrl, .T. )
oFTP:nConnTimeout := 20000
oFTP:bUsePasv := .T.
oFtp:bTrace := {|| .t.}
oFTP:Open( )
IF oFtp <> NIL
   RETURN .T.
ENDIF
RETURN .F.

******************************************************************************
FUNCTION SubeArchivoFtp(cFileOri,cFileDes,oFtp)
oFtp:Dele( cFileDes )
oFtp:UpLoadFile( cFileOri, cFileDes )
RETURN .T.
 
User avatar
cmsoft
 
Posts: 1290
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: ftp upload/download

Postby damianodec » Tue Feb 08, 2022 2:56 pm

thank you!
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
 
Posts: 419
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: ftp upload/download

Postby santidedos » Sat Feb 19, 2022 7:23 pm

Hola Cesar

Quise compilar el módulo pero me tira el siguiente error

Code: Select all  Expand view  RUN

Turbo Incremental Link 6.70 Copyright (c) 1997-2014 Embarcadero Technologies, Inc.
Error: Unresolved external 'URLDownloadToFileA' referenced from C:\FWH1701\SAMPLES\FTP2.OBJ
Error: Unable to perform link
* Linking errors *
 

Alguna idea? desde ya muchísimas gracias

Saludos
santidedos
 
Posts: 45
Joined: Fri Aug 16, 2019 12:51 am

Re: ftp upload/download

Postby cmsoft » Sat Feb 19, 2022 8:06 pm

santidedos wrote:Quise compilar el módulo pero me tira el siguiente error

Tienes que enlazar la librería de Borland urlmon.lib
User avatar
cmsoft
 
Posts: 1290
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: ftp upload/download

Postby santidedos » Sat Feb 19, 2022 9:05 pm

Ahí compiló. Gracias!!
santidedos
 
Posts: 45
Joined: Fri Aug 16, 2019 12:51 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 69 guests

cron