FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Subiendo y bajando archivos al FTP
Posts: 234
Joined: Tue Oct 25, 2005 12:39 AM
Subiendo y bajando archivos al FTP
Posted: Mon Jan 28, 2008 04:26 AM

Lo siguiente funciona para bajar un archivo de un ftp.

function testftp()

local oInternet := TInternet():New()
local oFTP := TFTP():New( "ftp.captura-digital.com", oInternet, "user","pass" )

if ! Empty( oFTP:hFTP )
Ftpgetfile( oFTP:hFTP,"nancy.xls","c:\ok\nancy.xls" )

¿¿ Y para subir un archivo ?? :-)

Fernando Leal
México, DF

Posts: 428
Joined: Thu Oct 19, 2006 12:28 PM
Subiendo y bajando archivos al FTP
Posted: Mon Jan 28, 2008 07:46 AM
Aqui te pongo como lo envio yo
#include "fivewin.ch"

Function Mandaf(fichero)
Local oInternet, oFtp, cServFtp:="ftp.tuftp.com",cUserFTp:="usuario",cPassFtp:="password"

oInternet := TInternet():New()
oFTP := TFTP():New( Alltrim(cServFtp), oInternet, Alltrim(cUserFtp),Alltrim(cPassFtp) )

If ! Empty( oFTP:hFTP )
FtpSendFiles ({fichero},{"Aqui pones la carpeta del ftp donde lo quieres enviar"+fichero},oFtp)

Endif
oInternet:End()

Return (nil)

Function FTPSendFiles ( aSource, aTarget, oFTP )
Local nBufSize:=4096
local n
local hSource
local cBuffer := Space( nBufSize )
local nBytes, nFile := 0, nTotal := 0
local nTotSize := 0
local oFile


for n = 1 to Len( aSource )
if ! File( aSource[ n ] )
MsgStop( "Fichero no encontrado: " + aSource[ n ] )
exit
endif
hSource = FOpen( aSource[ n ] )
nTotSize += FSeek( hSource, 0, 2 )
FClose( hSource )
SysRefresh()
next

for n = 1 to Len( aSource )
hSource = FOpen( aSource[ n ] )

oFile = TFtpFile():New( aTarget[ n ], oFTP )
oFile:OpenWrite()

FSeek( hSource, 0, 0 )
nFile := 0
SysRefresh()
while ( nBytes := FRead( hSource, @cBuffer, nBufSize ) ) > 0
oFile:Write( SubStr( cBuffer, 1, nBytes ) )
SysRefresh()
end
FClose( hSource )
oFile:End()
next
return nil


Saludos

Jose Luis
--------------------------

Saludos



Jose Luis
Posts: 234
Joined: Tue Oct 25, 2005 12:39 AM
ok
Posted: Mon Jan 28, 2008 08:20 PM

Jose Luis,

Ha funcionado a la primera !

Gracias por ayudarme

Continue the discussion