by postinelli » Fri Dec 09, 2011 12:10 pm
así lo hago yo, con FiveWin y xHarbour
MsgRun( "Enviando Datos por Ftp...", "Ftp",;
{ || FtpSend(salida,cServerFtp,cUserFtp,cPassFtp) } )
//----------------------------------------------------------------------------//
Function FTPSendFiles( cFTPSite, aSource, aTarget, cUserFtp, cPassFtp )
Local lEnd := .f.
Local nBufSize := 2000
Local oInternet, oFTP
MsgRun( "Conectando al Sitio FTP...", "Espere...",;
{ || oInternet := TInternet():New(),;
If( Empty( oInternet:hSession ),;
MsgAlert( "Sin Conexión a Internet!" ),),;
oFTP := TFTP():New( cFTPSite, oInternet, Alltrim(cUserFtp),Alltrim(cPassFtp) ) } )
if Empty( oFTP:hFTP )
MsgStop( "Imposible Conectarse al Sito FTP!" )
return nil
endif
SendFiles( aSource, aTarget, nBufSize, lEnd, oFTP )
oInternet:End()
return nil
//----------------------------------------------------------------------------//
Static Function SendFiles( aSource, aTarget, nBufSize, lEnd, oFTP )
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( "Archivo No Encontrado: " + aSource[ n ] )
exit
endif
hSource = FOpen( aSource[ n ] )
nTotSize += FSeek( hSource, 0, 2 )
FClose( hSource )
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
while ( nBytes := FRead( hSource, @cBuffer, nBufSize ) ) > 0 .and. ! lEnd
oFile:Write( SubStr( cBuffer, 1, nBytes ) )
end
FClose( hSource )
oFile:End()
if lEnd
exit
endif
next
Return nil
//----------------------------------------------------------------------------//