Send file via FTP - SOLVED

Send file via FTP - SOLVED

Postby Jeff Barnes » 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?

Code: Select all  Expand view

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
 
Last edited by Jeff Barnes on Thu Feb 07, 2013 6:07 pm, edited 1 time in total.
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Send file via FTP

Postby StefanHaupt » Wed Feb 06, 2013 7: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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Send file via FTP

Postby Colin Haig » Wed Feb 06, 2013 7:52 am

Hi Jeff

I have similar code except for

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

Cheers

Colin
Colin Haig
 
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: Send file via FTP

Postby Jeff Barnes » Wed Feb 06, 2013 2: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)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Send file via FTP

Postby StefanHaupt » Wed Feb 06, 2013 3: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: Select all  Expand view
METHOD New( oUrl,lTrace, oCredentials) CLASS tIPClientFTP )
 


Code: Select all  Expand view
oFtp := tIPClientftp():New(oUrl,.t.)
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Send file via FTP

Postby Jeff Barnes » Wed Feb 06, 2013 7:06 pm

xHarbour release 9421
Thanks,
Jeff Barnes

(FWH 16.11, xHarbour 1.2.3, Bcc730)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Send file via FTP

Postby StefanHaupt » Thu Feb 07, 2013 7:29 am

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

It´s a xharbour problem
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Send file via FTP - SOLVED

Postby Jeff Barnes » Thu Feb 07, 2013 6:05 pm

Got it working.

Here is the code that finally worked....


Code: Select all  Expand view

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)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada


Return to FiveWin for Harbour/xHarbour

Who is online

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