Resource icon

Harbour: send file via FTP

Harbour: send file via FTP

FTP_TEST.PRG
C:
// www.idlagam.com
// Servidor, credenciais FTP:
#define FTP_SERVER        'ftp.xxxxxx.bbb'
#define FTP_USER          'nome@xxxxx.bbb'
#define FTP_PWD           'senha123'

function main
   FTP_UpLoad( 'tabelaPreco.zip' )
   return nil

function FTP_UpLoad( cFileName ) // --> lSent
   local oURL
   local lSent

   IF ! FILE(cFileName)
      ? 'Arquivo não encontrado: ', cFileName
      RETURN .F.
   ENDIF
   with object oURL := TUrl():New()
      :cProto   :='ftp'
      :cUserid  :=FTP_USER
      :cPassword:=FTP_PWD
      :cServer  :=FTP_SERVER
   end with

   lSent:=.f.
   with object TIPClientFTP():New( oURL, .F. )
      :nConnTimeout := 20000
  
      ? 'conectando', FTP_SERVER, '...'
      if :open()
  
         ? 'conectado'

         ? 'UploadFile', cFileName
         if :UploadFile( cFileName )
            lSent:=.t.
         else
            ?? 'Erro'
         endif

         ? 'desconectando...'
         :close()
         ?? 'OK'
      else
         ?? 'ERRO'
  
      endif
   end with
   return lSent
Para compilar:
Bash:
hbmk2 FTP_TEST hbtip.hbc
Autor
Hurricane
Visualizações
224
Lançamento
Últ. atualização
Classificação
0,00 estrela(s) 0 avaliações
Top