file to FTP

file to FTP

Postby Natter » Sat May 02, 2009 12:26 pm

Hi, all !

I have total access to directory ftp. How I can copy file to this directory ?
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: file to FTP

Postby Otto » Sat May 02, 2009 2:26 pm

Natter, have you tried with:

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

best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: file to FTP

Postby Natter » Sat May 02, 2009 7:28 pm

Otto, thanks for your help.

What is "nConnect" ? What use - TFTP or TFTPClient ?
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: file to FTP

Postby Otto » Sat May 02, 2009 7:35 pm

Natter,
I use this code for FtpGetFile. But I think this should also work with FtpPutFile.
Best regards,
Otto

Code: Select all  Expand view
// 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

//----------------------------------------------------------------------------//
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: file to FTP

Postby Natter » Sat May 02, 2009 8: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.
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: file to FTP

Postby Otto » Sat May 02, 2009 8:47 pm

Natter, what error do you get?
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: file to FTP

Postby Natter » Sat May 02, 2009 8:59 pm

I not get error, but and file not copy to FTP
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am

Re: file to FTP

Postby Otto » Sat May 02, 2009 9: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: file to FTP

Postby Natter » Sun May 03, 2009 7: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
Natter
 
Posts: 1215
Joined: Mon May 14, 2007 9:49 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 95 guests