FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour file to FTP
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM

file to FTP

Posted: Sat May 02, 2009 12:26 PM

Hi, all !

I have total access to directory ftp. How I can copy file to this directory ?

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM

Re: file to FTP

Posted: Sat May 02, 2009 02:26 PM

Natter, have you tried with:

FTPPutFile( hConnect, cUpFile, cUpFile, 0, 0 )

best regards,
Otto

Posts: 1392
Joined: Mon May 14, 2007 09:49 AM

Re: file to FTP

Posted: Sat May 02, 2009 07:28 PM

Otto, thanks for your help.

What is "nConnect" ? What use - TFTP or TFTPClient ?

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM

Re: file to FTP

Posted: Sat May 02, 2009 07:35 PM
Natter,
I use this code for FtpGetFile. But I think this should also work with FtpPutFile.
Best regards,
Otto

Code (fw): Select all Collapse
// Testing the FiveWin new Internet Classes

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()
   local oWnd, oTmr

   DEFINE WINDOW oWnd TITLE "Timers"

   DEFINE TIMER oTmr  INTERVAL 10000 ACTION  (oTmr:DeActivate(),oWnd:Say( 10, 17, Time() ), upload(),oTmr:Activate() ) of oWnd
   ACTIVATE TIMER oTmr

   ACTIVATE WINDOW oWnd ;
      ON CLICK MsgInfo( "Click!" )

   oTmr:End()

return nil

//----------------------------------------------------------------------------//

FUNC upload()
   local oInternet := TInternet():New()
   local oFTP      := TFTP():New( "ftp.test.info", oInternet,"testinfo", "test" )
   local aFiles
   LOCAL handle
   local cFile     := ""

   if ! Empty( oFTP:hFTP )

/*
DLL32 FUNCTION FtpSetCurrentDirectory(
hFTP AS LONG,
cDirName AS LPSTR ) ;
AS BOOL PASCAL ;
*/
   FtpSetCurrentDirectory(oFTP:hFTP,  "/testinfo/STB1/")
   aFiles = oFTP:Directory("*.*" )

   IF len(aFiles) > 0

      AEval( aFiles, { | aFile | msginfo( aFile[ 1 ] ),cFile := ALLTRIM( aFile[ 1 ] ),;
         FtpGetFile (oFTP:hFTP,aFile[ 1 ], "c:\dbf\" + aFile[ 1 ] ,.t.,0,0,0 ) ,;
         oFTP:DeleteFile( aFile[ 1 ]) } )

   ENDIF


/*
DLL32 FUNCTION FtpGetFile(
hFTP AS LONG,      = INTERNETCONNECT
cRemoteFile AS LPSTR
cLocalFile AS LPSTR
lOverWrite AS LONG
n1 AS LONG
n2 AS LONG
n3 AS LONG
*/

else
   MsgAlert( "oFTP:hFTP is null" )
endif

oInternet:End()

//MsgInfo( "Done!" )

return nil

//----------------------------------------------------------------------------//
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM

Re: file to FTP

Posted: Sat May 02, 2009 08:42 PM

Copy file from FTP to local computer I do with URLDownloadToFile() - it work fine.
If do FTPPutFile() from TFTP then It's not work.

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM

Re: file to FTP

Posted: Sat May 02, 2009 08:47 PM

Natter, what error do you get?
Best regards,
Otto

Posts: 1392
Joined: Mon May 14, 2007 09:49 AM

Re: file to FTP

Posted: Sat May 02, 2009 08:59 PM

I not get error, but and file not copy to FTP

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM

Re: file to FTP

Posted: Sat May 02, 2009 09:44 PM
Natter,
how do you test that you have full access as you write in your first post?

if FTPPUTFILE( hConnect, CurDir() +"\"+ aInfo[I,1], "/testinfo/STB1/"+aInfo[I,1], 0, 0 )=.t.

I have some FTP servers where the name for example is
test.info and the directory STB1.
Via http:// I can use www.test.info/STB1 but

/STB1 does not work via FTP.

I have to use to access via FTP /testinfo/STB1 .

Best regards,
Otto
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM

Re: file to FTP

Posted: Sun May 03, 2009 07:17 AM

I do then :

function Main()
local oInternet := TInternet():New()
local oFTP := TFTP():New( "ftp.MyFtp", oInternet, login, password )

? oFTP = object
? oFTP:hFtp >0

? FTPPutFile( oFTP:hFtp, LocalFile, FtpFile, 0, 0 ) = .F.

return NIL

Examle .\samles\ftpdir.prg with this parameters work fine

Continue the discussion