FTP Again

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

FTP Again

Post by Colin Haig »

Hi All

Still having a problem sending a file from a Samsung Omnia using Windows Mobile 6.1
this is the code I am using - I dont get any errors but the file is never transferred.

Any ideas greatfully accepted.


static function Connect()
LOCAL hInternet, hConnect

hInternet = INTERNETOPEN( "Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )
if hInternet == 0
MsgInfo('No Internet')
endif

hConnect = INTERNETCONNECT( hInternet,"99.9.9.99",INTERNET_DEFAULT_FTP_PORT, "user", "pass", INTERNET_SERVICE_FTP,0, 0 )
IF HConnect == 0
MSGINFO("Error on FTP Connection ")
RETURN .F.
ENDIF
FTPPUTFILE( hConnect, "\\My Storage\\mobapp\\user.dbf", "user.dbf", 0, 0 )

INTERNETCLOSEHANDLE( hConnect )

INTERNETCLOSEHANDLE( hInternet )

RETURN NIL

Regards

Colin
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: FTP Again

Post by Enrico Maria Giordano »

Try passive mode:

Code: Select all

#define INTERNET_FLAG_PASSIVE 134217728

hConnect = INTERNETCONNECT( hInternet,"99.9.9.99",INTERNET_DEFAULT_FTP_PORT, "user", "pass", INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE, 0 )
EMG
Colin Haig
Posts: 310
Joined: Mon Oct 10, 2005 5:10 am

Re: FTP Again

Post by Colin Haig »

Hi Enrico

Thanks for that suggestion but still no luck - I changed the code to give a return value from
ftpputfile and it always returns false - I have tried sending the file to two different servers and
still no luck - they are both windows 2003 servers.

I have used the tip class (xHarbour) to ftp file from within my normal fivewin app and that works fine to both
servers. I have tried the ftp at command line to connect to both servers and that works.

Can it be the path settings for the files that is causing an issue - or can you reccomend another way
of testing it.

Do you know if there is a ftp program that works on windows mobile so I could just make sure the device can
actually ftp.

Thanks for any help and assistance

regards

Colin
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: FTP Again

Post by Enrico Maria Giordano »

Code: Select all

FTPPUTFILE( hConnect, "\\My Storage\\mobapp\\user.dbf", "user.dbf", 0, 0 )
Try to provide the correct full path for the remote file (third parameter).

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

Re: FTP Again

Post by Colin Haig »

Hi Enrico

I think I have tried every combination of paths - I downloaded a ftp client and tested that
and it works fine.

So I am not sure what to try next.

Thanks for your suggestions.

Regards

Colin
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: FTP Again

Post by Enrico Maria Giordano »

Please build a reduced and self-contained sample of the problem and show it here.

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

Re: FTP Again

Post by Colin Haig »

Hi Enrico

Here is the code - I have removed as much as possible
There is a sub folder called BMP - c:\mobapp\bmp

Thanks for your assistance

Colin

#define FILE_ATTRIBUTE_READONLY 1
#define FILE_ATTRIBUTE_HIDDEN 2
#define FILE_ATTRIBUTE_SYSTEM 4
#define FILE_ATTRIBUTE_DIRECTORY 16
#define FILE_ATTRIBUTE_ARCHIVE 32
#define FILE_ATTRIBUTE_NORMAL 128
#define FILE_ATTRIBUTE_TEMPORARY 256

//
// access types for InternetOpen()
//

#define INTERNET_OPEN_TYPE_PRECONFIG 0 // use registry configuration
#define INTERNET_OPEN_TYPE_DIRECT 1 // direct to net
#define INTERNET_OPEN_TYPE_PROXY 3 // via named proxy
#define INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY 4 // prevent using java/script/INS


//
// manifests
//

#define INTERNET_INVALID_PORT_NUMBER 0 // use the protocol-specific default

#define INTERNET_DEFAULT_FTP_PORT 21 // default for FTP servers
#define INTERNET_DEFAULT_GOPHER_PORT 70 // " " gopher "
#define INTERNET_DEFAULT_HTTP_PORT 80 // " " HTTP "
#define INTERNET_DEFAULT_HTTPS_PORT 443 // " " HTTPS "
#define INTERNET_DEFAULT_SOCKS_PORT 1080 // default for SOCKS firewall servers.


//
// service types for InternetConnect()
//

#define INTERNET_SERVICE_FTP 1
#define INTERNET_SERVICE_GOPHER 2
#define INTERNET_SERVICE_HTTP 3

#define INTERNET_FLAG_PASSIVE 134217728

//
// flags for FTP
//

#define INTERNET_FLAG_TRANSFER_ASCII 1
#define INTERNET_FLAG_TRANSFER_BINARY 2



#define SHFS_HIDETASKBAR 2 // 0x0002 //2
#define SHFS_SHOWSIPBUTTON 4 // 0x0004
#define SHFS_HIDESIPBUTTON 8 // 0x0008 //8
#define SHFS_SHOWSTARTICON 16 // 0x0010
#define SHFS_HIDESTARTICON 20 // 0x0020 //
#define TRUE .T.
#define FALSE .F.
#include "C:\FWPPC\INCLUDE\FWCE.CH"
static oWnd
function Main()
local oFont
REQUEST DBFCDX,DBFFPT
RddSetDefault('DBFCDX')
config()
use(curdir() +'\user')
cIntls := user->intls
cName := user->employee
use
DEFINE FONT oFont NAME "Cambria" SIZE 0,-9
DEFINE WINDOW oWnd

ShFullScreen(oWnd:hwnd,SHFS_HIDESTARTICON )
ShFullScreen(oWnd:hwnd,SHFS_HIDETASKBAR )


ACTIVATE WINDOW oWnd ;
ON INIT(MoveWindow(oWnd:hWnd,0,0,300,320),;
Control())


dbCloseall()
oFont:end()
return nil
//---------------------------------------------------------------------------//
function config()
set date british
set softseek on
set confirm on
set deleted on
set century on
set epoch to 1960
return(nil)
//---------------------------------------------------------------------------//
static function Control()
local lClean := FALSE

@50,25 BTNBMP FILE Curdir() +'\bmp\clock_red.bmp' SIZE 28, 28 OF oWnd ;
ACTION(Timesheets(cIntls,cName))

@50,100 BTNBMP FILE Curdir() +'\bmp\transmit.bmp' SIZE 28, 28 OF oWnd ;
ACTION(Connect())

@50,175 BTNBMP FILE Curdir() +'\bmp\group.bmp' SIZE 28, 28 OF oWnd ;
ACTION(ShowAll(cIntls,cName))

@100,25 BTNBMP FILE Curdir() +'\bmp\house.bmp' SIZE 28, 28 OF oWnd ;
ACTION(lClean := FALSE,Maint(lClean))

@100,100 BTNBMP FILE Curdir() +'\bmp\delete.bmp' SIZE 28, 28 OF oWnd ;
ACTION(lClean := TRUE,Maint(lClean))

@100,175 BTNBMP FILE Curdir() +'\bmp\exit.bmp' SIZE 28, 28 OF oWnd ;
ACTION(dbCloseAll(),oWnd:end())

return(nil)
//---------------------------------------------------------------------------//
static function Timesheets(cIntls,cName)
MsgInfo('timesheet code')
return(nil)
//--------------------------------------------------------------//
static function ShowAll()
MsgInfo('display all records in browse')
return(nil)
//-----------------------------------------------------------------//
static function files()
MsgInfo('check for indexes')
return(nil)
//---------------------------------------------------------------------------------------//
static function Maint(lClean)
MsgInfo('re index')
RETURN(NIL)
//-----------------------------------------------------------------------------------------//
static function Connect()
LOCAL hInternet, hConnect

// I have tried "anystring" as well as the IP

hInternet = INTERNETOPEN( "99.9.9.999", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )
if hInternet == 0
MsgInfo('No Internet')
endif

hConnect = INTERNETCONNECT( hInternet,"99.9.9.999",INTERNET_DEFAULT_FTP_PORT, "admin", "#pass",
INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE, 0 )
IF HConnect == 0
MSGINFO("Error on FTP Connection ")
RETURN .F.
ENDIF
if ! FTPPUTFILE( hConnect, "\\My Storage\MobApp\error.txt", "c:\fpt\error.txt", 0, 0 )
MsgAlert('FTP failed') // fails here
endif
INTERNETCLOSEHANDLE( hConnect )
INTERNETCLOSEHANDLE( hInternet )
RETURN(NIL)
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: FTP Again

Post by Enrico Maria Giordano »

Code: Select all

FTPPUTFILE( hConnect, "\\My Storage\MobApp\error.txt", "c:\fpt\error.txt", 0, 0 )
This is wrong. The third parameter must be the remote file in FTP format (ie. /emagsoftware.it/ftp/error.txt on my website).

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

Re: FTP Again

Post by Colin Haig »

Hi Enrico

Thanks that worked - I must have googled for ages trying to get a sample of the
path - I thought the / was for Linux boxes - anyway I just changed my code to "/error.txt"
and it worked.

Thanks for your patience.

Cheers

Colin
Post Reply