Estimado Colegas
He probado con todas las opciones del foro para subir y bajar archivos por ftp ,
Para subir los archivos no tengo ningun problema , el tema es que no puedo bajarlos
Si alguien me puede orientar como solucionar este problema gracias
Fabian
Ayuda FTP , puedo subir archivos , pero no bajarlos
-
- Posts: 38
- Joined: Tue Jul 17, 2007 12:37 pm
-
- Posts: 113
- Joined: Wed Mar 11, 2009 7:32 pm
- Location: Obregon, Sonora, Mexico
Re: Ayuda FTP , puedo subir archivos , pero no bajarlos
hola
yo uso esto
saludos
yo uso esto
saludos
Code: Select all
// Testing the FiveWin new Internet Classes
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
local aFiles
local ctime1, ctime2
FTPGetFile( "127.0.0.1", "perla.dbf","sopas.dbf", "benji", "xxxx", 14147)
use sopas
browse()
return NIl
FUNCTION FtpSendFile( cFTPSite, cSource, cTarget, cUser, cPass, nBufSize )
LOCAL oInternet, oFTP
DEFAULT cUser:="", cPass:="", nBufSize:=2000
IF EMPTY(cFtpSite) .or. EMPTY(cSource) .or. EMPTY(cTarget)
MsgInfo("Missing Parameters"+chr(13)+"Usage: FtpSendFile(cFtpSite, cSource, cTarget, cUser, cPass, nBufSize) ","FtpSendFile()")
Return .f.
ENDIF
oInternet := TInternet():New()
IF Empty( oInternet:hSession )
MsgAlert( "Internet session not available!" )
ELSE
oFTP := TFTP():New( cFTPSite, oInternet, cUser, cPass )
IF Empty( oFTP:hFTP )
MsgStop( "Cannot connect to "+cFtpSite )
oInternet:End()
return .f.
ENDIF
ENDIF
SendFiles( cSource, cTarget, nBufSize, oFTP )
oInternet:End()
return nil
//----------------------------------------------------------------------------//
static function SendFiles( cSource, cTarget, nBufSize, oFTP )
local hSource
local cBuffer := Space( nBufSize )
local nBytes
local oFile
if ! File( cSource )
MsgStop( "File not found: " + cSource )
Return .f.
endif
hSource = FOpen( cSource )
oFile = TFtpFile():New( cTarget, oFTP )
oFile:OpenWrite()
FSeek( hSource, 0, 0 )
nFile := 0
while ( nBytes := FRead( hSource, @cBuffer, nBufSize ) ) > 0
oFile:Write( SubStr( cBuffer, 1, nBytes ) )
end
FClose( hSource )
oFile:End()
return .t.
//----------------------------------------------------------------------------//
function FTPGetFile( cFTPSite, cSource, cTarget, cUser, cPass, nBufSize )
local oInternet, oFTP
DEFAULT cUser:="", cPass:="", nBufSize:=2000
IF EMPTY(cFtpSite) .or. EMPTY(cSource) .or. EMPTY(cTarget)
MsgInfo("Missing Parameters"+chr(13)+"Usage: FtpGetFile(cFtpSite, cSource, cTarget, cUser, cPass, nBufSize) ","FtpSendFile()")
Return .f.
ENDIF
oInternet := TInternet():New()
IF Empty( oInternet:hSession )
MsgAlert( "Internet session not available!" )
oInternet:End()
return .f.
ELSE
oFTP := TFTP():New( cFTPSite, oInternet, cUser, cPass )
if Empty( oFTP:hFTP )
MsgStop( "Cannot connect to "+cFtpSite)
oInternet:End()
return .f.
endif
ENDIF
GetFiles( cSource, cTarget, nBufSize, oFTP )
oInternet:End()
return .t.
//----------------------------------------------------------------------------//
static function GetFiles( cSource, cTarget, nBufSize, oFTP )
local hTarget
local cBuffer := Space( nBufSize )
local nBytes
local oFile, aFiles
hTarget = FCreate( cTarget )
oFile = TFtpFile():New( cSource, oFTP )
oFile:OpenRead()
while ( nBytes := Len( cBuffer := oFile:Read( nBufSize ) ) ) > 0
FWrite( hTarget, cBuffer, nBytes )
end
FClose( hTarget )
oFile:End()
return nil
//----------------------------------------------------------------------------//
function FtpIsFile(cFtpSite, cFile, cUser, cPass, lDelete)
local oInternet := TInternet():New()
local oFTP := TFTP():New( cFtpSite, oInternet, cUser, cPass )
local aFiles, lFound:=.f.
DEFAULT cUser := "", cPass:="", lDelete:=.f.
IF EMPTY(cFtpSite) .or. EMPTY(cFile)
Msginfo("Missing Parameters"+chr(13)+"Usage: CheckFtpFile(cFtpSite, cFile, cUser, cPass, lDelete) ","CheckFtpFile()")
Return .f.
ENDIF
IF ! Empty( oFTP:hFTP )
aFiles = oFTP:Directory( "*.*" )
AEval( aFiles, { | aFile | IIF( aFile[ 1 ] = cFile,(lFound:=lDeleted:=.t.), ) } )
ENDIF
if lDelete
if lFound
oFtp:deletefile(cFile)
msginfo("deleteed")
endif
endif
oInternet:End()
return lFound
Benjamin Casarrubias Moreno
Cd. Obregon, Sonora, Mexico
chino72vale@hotmail.com
Fivewin 16.05, Harbour 3.2, xharbour 1.2.1, Fivelinux, visual estudio 2013
Cd. Obregon, Sonora, Mexico
chino72vale@hotmail.com
Fivewin 16.05, Harbour 3.2, xharbour 1.2.1, Fivelinux, visual estudio 2013