FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Send file via FTP - SOLVED
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Send file via FTP - SOLVED
Posted: Tue Feb 05, 2013 11:36 PM
I have an issue sending a file via FTP.
I have copied the code directly from another app of mine where the code works perfectly (it was compiled with an older version of FWH / xHarbour)

When I try with my current FWH / xHarbour it never connects.
I have verified the user/pass. If I copy the string (cUrl) into my browser it will connect.

Any idea of what I have missed or has something changed in FWH/xHarbour?
cUrl := "ftp://myUser:myPass@mySite.net"
oUrl := tUrl():New(cUrl)
            
oFtp := tIPClientftp():New(oUrl,,.t.)
oFtp:nConnTimeout := 60000
oFtp:bUsePasv     := .t.
                    
IF oFtp:open(cUrl)
   IF oFtp:UpLoadFile(cZipFile)  
       MsgInfo("Sent")
   ELSE
       MsgInfo("Not Sent")
   ENDIF
   oFtp:Close()
ELSE
   MsgInfo("Not Connected")   //  <-- This is always the responce 
ENDIF
Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Send file via FTP
Posted: Wed Feb 06, 2013 07:34 AM

Jeff,

tIpClientFtp is a class of xHarbour, maybe something was changed in the last releases.

What version of xHarbour are you using ?

kind regards

Stefan
Posts: 310
Joined: Mon Oct 10, 2005 05:10 AM
Re: Send file via FTP
Posted: Wed Feb 06, 2013 07:52 AM

Hi Jeff

I have similar code except for

cUrl := "ftp://" + cUser + ":" + cPassword + "@" + cServer

Cheers

Colin

Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: Send file via FTP
Posted: Wed Feb 06, 2013 02:18 PM

Hi Stefan,

I am currently using: FWH 12.01, xHarbour 1.2.1, Bcc582

Hi Colin

Your cUrl is the same as mine ... I am not using variables is the only difference :)

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Send file via FTP
Posted: Wed Feb 06, 2013 03:57 PM
Jeff,

which release of xHarbour ?

I´m using release 9411 and your sample is working here

BTW, in your line oFtp := tIPClientftp():New(oUrl,,.t.) you should delete on comma
from TClientFtp.prg
Code (fw): Select all Collapse
METHOD New( oUrl,lTrace, oCredentials) CLASS tIPClientFTP )


Code (fw): Select all Collapse
oFtp := tIPClientftp():New(oUrl,.t.)
kind regards

Stefan
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: Send file via FTP
Posted: Wed Feb 06, 2013 07:06 PM

xHarbour release 9421

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Send file via FTP
Posted: Thu Feb 07, 2013 07:29 AM

I checked with release 9804, it´s connecting but the file is not sent.

It´s a xharbour problem

kind regards

Stefan
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: Send file via FTP - SOLVED
Posted: Thu Feb 07, 2013 06:05 PM
Got it working.

Here is the code that finally worked....
cUrl := "ftp://MyUser:MyPassword@MyServer.com"
oUrl:=TUrl():NEW( cUrl )
oUrl:cUserID:="MyUser"
oUrl:cPassword:="MyPassword"
oUrl:cServer:="MyServer.com"
oUrl:cAddress:="ftp://MyUser:MyPassword@MyServer.com"
        
oFtp:=TIPClientFTP():New( oUrl )    
IF .NOT. oFtp:open()
   MsgInfo("Error: Could not connect."+CRLF+ oFtp:lastErrorMessage(),"ERROR" )
ELSE
   IF oFtp:UpLoadFile(cFile)   
      MsgInfo("sent")
   ELSE
      MsgInfo("not sent")
   ENDIF
   oFtp:Close() 
ENDIF
Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)

Continue the discussion