Problemas para Envio y Rececpcion de Archivos por FTP

Problemas para Envio y Rececpcion de Archivos por FTP

Postby Julio Perez » Fri Jan 22, 2010 12:35 pm

Buenas modifique el PRG ftp.prg que viene en los ejemplos para envio y recepcion de archivos pero al ejecutarlo no transfiere nada y no me da ningun mensaje de error por no enviar ni ningun mensaje que lo envio, agradezco la ayuda que puedan darme y de antemano muchas gracias estos son mis PRG:

Recibir:
======
Code: Select all  Expand view

// FTPrecibe

#include "Fwce.ch"

//
// File attributes
//

#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


//
// flags for FTP
//

#define INTERNET_FLAG_TRANSFER_ASCII  1
#define INTERNET_FLAG_TRANSFER_BINARY 2


FUNCTION MAIN()

    LOCAL hInternet, hConnect

    hInternet = INTERNETOPEN( "Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )

    hConnect = INTERNETCONNECT( hInternet, "FTP://LAPERCHA.DYNDNS.ORG", INTERNET_INVALID_PORT_NUMBER, "usuario", "clave", INTERNET_SERVICE_FTP, 0, 0 )

    ? FTPGETFILE( hConnect, "recibe.txt", "recibe.txt", 0, FILE_ATTRIBUTE_ARCHIVE, 0, 0 )
   
    INTERNETCLOSEHANDLE( hConnect )

    INTERNETCLOSEHANDLE( hInternet )

    RETURN NIL


#pragma BEGINDUMP

#include "windows.h"
#include "wininet.h"
#include "hbapi.h"


LPWSTR AnsiToWide( LPSTR );


HB_FUNC( INTERNETOPEN )
{
    LPWSTR cAgent = AnsiToWide( hb_parc( 1 ) );
    LPWSTR cProxyName = AnsiToWide( hb_parc( 3 ) );
    LPWSTR cProxyBypass = AnsiToWide( hb_parc( 4 ) );

    HINTERNET hInternet = InternetOpen( cAgent, hb_parnl( 2 ), cProxyName, cProxyBypass, hb_parnl( 5 ) );

    hb_xfree( cAgent );
    hb_xfree( cProxyName );
    hb_xfree( cProxyBypass );

    hb_retnl( ( LONG ) hInternet );
}


HB_FUNC( INTERNETCLOSEHANDLE )
{
    hb_retl( InternetCloseHandle( ( HINTERNET ) hb_parnl( 1 ) ) );
}


HB_FUNC( INTERNETCONNECT )
{
    LPWSTR cServerName = AnsiToWide( hb_parc( 2 ) );
    LPWSTR cUserName = AnsiToWide( hb_parc( 4 ) );
    LPWSTR cPassword = AnsiToWide( hb_parc( 5 ) );

    HINTERNET hInternet = InternetConnect( ( HINTERNET ) hb_parnl( 1 ), cServerName, ( INTERNET_PORT ) hb_parnl( 3 ), cUserName, cPassword, hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ) );

    hb_xfree( cServerName );
    hb_xfree( cUserName );
    hb_xfree( cPassword );

    hb_retnl( ( LONG ) hInternet );
}


HB_FUNC( FTPGETFILE )
{
    LPWSTR cRemoteFile = AnsiToWide( hb_parc( 2 ) );
    LPWSTR cNewFile = AnsiToWide( hb_parc( 3 ) );

    hb_retl( FtpGetFile( ( HINTERNET ) hb_parnl( 1 ), cRemoteFile, cNewFile, hb_parl( 4 ), hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ) ) );

    hb_xfree( cRemoteFile );
    hb_xfree( cNewFile );
}


HB_FUNC( FTPPUTFILE )
{
    LPWSTR cLocalFile = AnsiToWide( hb_parc( 2 ) );
    LPWSTR cNewRemoteFile = AnsiToWide( hb_parc( 3 ) );

    hb_retl( FtpPutFile( ( HINTERNET ) hb_parnl( 1 ), cLocalFile, cNewRemoteFile, hb_parnl( 4 ), hb_parnl( 5 ) ) );

    hb_xfree( cLocalFile );
    hb_xfree( cNewRemoteFile );
}

#pragma ENDDUMP


Envia
=====
Code: Select all  Expand view
// FTPenvia

#include "Fwce.ch"

//
// File attributes
//

#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


//
// flags for FTP
//

#define INTERNET_FLAG_TRANSFER_ASCII  1
#define INTERNET_FLAG_TRANSFER_BINARY 2


FUNCTION MAIN()

    LOCAL hInternet, hConnect

    hInternet = INTERNETOPEN( "Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )

    hConnect = INTERNETCONNECT( hInternet, "FTP://LAPERCHA.DYNDNS.ORG", INTERNET_INVALID_PORT_NUMBER, "usuario", "clave", INTERNET_SERVICE_FTP, 0, 0 )

    ? FTPPUTFILE( hConnect, "envia.txt", "envia.txt", 0, 0 )

    INTERNETCLOSEHANDLE( hConnect )

    INTERNETCLOSEHANDLE( hInternet )

    RETURN NIL


#pragma BEGINDUMP

#include "windows.h"
#include "wininet.h"
#include "hbapi.h"


LPWSTR AnsiToWide( LPSTR );


HB_FUNC( INTERNETOPEN )
{
    LPWSTR cAgent = AnsiToWide( hb_parc( 1 ) );
    LPWSTR cProxyName = AnsiToWide( hb_parc( 3 ) );
    LPWSTR cProxyBypass = AnsiToWide( hb_parc( 4 ) );

    HINTERNET hInternet = InternetOpen( cAgent, hb_parnl( 2 ), cProxyName, cProxyBypass, hb_parnl( 5 ) );

    hb_xfree( cAgent );
    hb_xfree( cProxyName );
    hb_xfree( cProxyBypass );

    hb_retnl( ( LONG ) hInternet );
}


HB_FUNC( INTERNETCLOSEHANDLE )
{
    hb_retl( InternetCloseHandle( ( HINTERNET ) hb_parnl( 1 ) ) );
}


HB_FUNC( INTERNETCONNECT )
{
    LPWSTR cServerName = AnsiToWide( hb_parc( 2 ) );
    LPWSTR cUserName = AnsiToWide( hb_parc( 4 ) );
    LPWSTR cPassword = AnsiToWide( hb_parc( 5 ) );

    HINTERNET hInternet = InternetConnect( ( HINTERNET ) hb_parnl( 1 ), cServerName, ( INTERNET_PORT ) hb_parnl( 3 ), cUserName, cPassword, hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ) );

    hb_xfree( cServerName );
    hb_xfree( cUserName );
    hb_xfree( cPassword );

    hb_retnl( ( LONG ) hInternet );
}


HB_FUNC( FTPGETFILE )
{
    LPWSTR cRemoteFile = AnsiToWide( hb_parc( 2 ) );
    LPWSTR cNewFile = AnsiToWide( hb_parc( 3 ) );

    hb_retl( FtpGetFile( ( HINTERNET ) hb_parnl( 1 ), cRemoteFile, cNewFile, hb_parl( 4 ), hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ) ) );

    hb_xfree( cRemoteFile );
    hb_xfree( cNewFile );
}


HB_FUNC( FTPPUTFILE )
{
    LPWSTR cLocalFile = AnsiToWide( hb_parc( 2 ) );
    LPWSTR cNewRemoteFile = AnsiToWide( hb_parc( 3 ) );

    hb_retl( FtpPutFile( ( HINTERNET ) hb_parnl( 1 ), cLocalFile, cNewRemoteFile, hb_parnl( 4 ), hb_parnl( 5 ) ) );

    hb_xfree( cLocalFile );
    hb_xfree( cNewRemoteFile );
}

#pragma ENDDUMP
Julio Perez
 
Posts: 24
Joined: Wed Nov 18, 2009 2:58 pm

Re: Problemas para Envio y Rececpcion de Archivos por FTP

Postby Antonio Linares » Mon Jan 25, 2010 6:52 pm

Julio,

Has comprobado que tengas bien configurado el acceso a internet desde el Windows Mobile ?

Puedes acceder a una página web desde el Internet Explorer ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41289
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Problemas para Envio y Rececpcion de Archivos por FTP

Postby Julio Perez » Mon Jan 25, 2010 7:27 pm

Si puedo acceder a una pagina WEB y al Servidor FTP de la compañia desde el HandHelp, pero el PRG que te envie no funciona ... Hermano
Julio Perez
 
Posts: 24
Joined: Wed Nov 18, 2009 2:58 pm

Re: Problemas para Envio y Rececpcion de Archivos por FTP

Postby Julio Perez » Mon Jan 25, 2010 7:32 pm

1.- Yo queria tener 2 formas de enviar Archivos, por FTP o por Correo de Fallarme el FTP o viceversa.

2.- En FWPPC solo se pueden usar imagenes BMP

3.- Existe alguna forma en FWPPC de comprimir varios archivos tipo ZIP para luego enviarlos por correo.

Y disculpa de verdad, por preguntar tanto es que mi Jefe me tiene presionado con el intercambio de informacion por los Haldhelp para la aquisicion de los otros equipos para implementar el 1 de Marzo de este año en curso.

Gracias hermano
Julio Perez
 
Posts: 24
Joined: Wed Nov 18, 2009 2:58 pm

Re: Problemas para Envio y Rececpcion de Archivos por FTP

Postby Daniel Garcia-Gil » Fri Jan 29, 2010 2:29 pm

Saludos Julio...


pienso que pudes tener un error en la ubicacion del archivo, debes asignar la rura exacta de la ubicacion del archivo local

te expongo un ejemplo muy sencillo usando las clases de FWPPC

pudo darte acceso a mi servidor FTP para que hagas pruebas
danielgarciagil@gmail.com

Code: Select all  Expand view

#include "Fwce.ch"


FUNCTION MAIN()

    LOCAL hInternet, hConnect
    local cData

    oInternet := tInternet():New()
    oFtp      := tFtp():New( "ftp.tuservidor.com", oInternet, "usuario", "clave" )
     
     
    // envia txt esta en la misma carpera del EXE  
    MsgInfo(  FtpPutFile( oFtp:hFtp, CurDir() + "\envia.txt", "envia.txt",  ;
                          0, ;
                          0 ) )
   
    oFtp:End()
    oInternet:End()                          

RETURN NIL

function GetLastError()
return 0
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Problemas para Envio y Rececpcion de Archivos por FTP

Postby Julio Perez » Mon Feb 01, 2010 5:23 pm

Muchas gracias amigo daniel voy a probar y cualquier cosa te aviso, de verdad que muchisimas gracias
Julio Perez
 
Posts: 24
Joined: Wed Nov 18, 2009 2:58 pm


Return to FiveWin para Pocket PC

Who is online

Users browsing this forum: No registered users and 3 guests