Upload files via FTP

Moderator: Enrico Maria Giordano

Post Reply
Romeo
Posts: 328
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Upload files via FTP

Post by Romeo »

Ciao a tutti,
tempo fa EMG mi ha dato una esempio per trasferire files su un area del web.
L'esempio, chiaramente mi funziona bene dato che sono collegato direttamente a internet.
Ho notato pero' che un mio cliente che e' collegato a internet tramite rete aziendale fa fatica a fare l'upload dei files.
Dove posso agire per dirgli che non sono collegato direttamente ad internet ?

Grazie
Romeo/Zingoni


Vi riporto l'esempio di EMG:

#include "Fivewin.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


STATIC hLib


FUNCTION MAIN()

LOCAL hInternet, hConnect

hLib = LOADLIB32( "wininet.dll" )

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

hConnect = INETCONNECT( hInternet, "ftp address", INTERNET_INVALID_PORT_NUMBER, "userid", "password", INTERNET_SERVICE_FTP, 0, 0 )

? FTPGETFILE( hConnect, "remote file", "local file", 0, FILE_ATTRIBUTE_ARCHIVE, 0, 0 )

// ? FTPPUTFILE( hConnect, "local file", "remote file", 0, 0 )

INETCLOSEHANDLE( hConnect )

INETCLOSEHANDLE( hInternet )

FREELIB32( hLib )

RETURN NIL


DLL32 FUNCTION INETOPEN( cAgent AS LPSTR, nAccessType AS DWORD, cProxyName AS LPSTR, cProxyBypass AS LPSTR, nFlags AS DWORD ) AS LONG;
PASCAL FROM "InternetOpenA" LIB hLib

DLL32 FUNCTION INETCLOSEHANDLE( hInternet AS LONG ) AS BOOL;
PASCAL FROM "InternetCloseHandle" LIB hLib

DLL32 FUNCTION INETCONNECT( hInternet AS LONG, cServerName AS LPSTR, nServerPort AS LONG, cUserName AS LPSTR, cPassword AS LPSTR, nService AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS LONG;
PASCAL FROM "InternetConnectA" LIB hLib

DLL32 FUNCTION FTPGETFILE( hConnect AS LONG, cRemoteFile AS LPSTR, cNewFile AS LPSTR, nFailIfExists AS LONG, nFlagsAndAttribs AS DWORD, nFlags AS DWORD, @nContext AS PTR ) AS BOOL;
PASCAL FROM "FtpGetFileA" LIB hLib

DLL32 FUNCTION FTPPUTFILE( hConnect AS LONG, cLocalFile AS LPSTR, cNewRemoteFile AS LPSTR, nFlags AS DWORD, @nContext AS PTR ) AS BOOL;
PASCAL FROM "FtpPutFileA" LIB hLib
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Upload files via FTP

Post by Enrico Maria Giordano »

Potresti provare con uno di questi:

Code: Select all

// 
// 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 
EMG
Romeo
Posts: 328
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Post by Romeo »

Non vedo differenze con il tuo vecchio esempio.
Tks
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Devi sostituire uno diverso di quei simboli nella seguente istruzione:

Code: Select all

hInternet = INETOPEN( "Anystring", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0 )
EMG
Post Reply