OVH Cloud OVH Cloud

envoi d'un fichier texte via ftp

3 réponses
Avatar
Pierre Bunoz
bonjour
je voudrais envoyer une requête (en fichier texte) sur un site ftp pour
lequel je connais
-l'adresse
-le login
-le mot de passe
exite-il une procédure vb existante ou faire référence à quelle bibliothèque
dans VB
Merci bien
Pierre

3 réponses

Avatar
Anor
Bonjour

Pierre Bunoz a confié :
| bonjour
| je voudrais envoyer une requête (en fichier texte) sur un site ftp
| pour lequel je connais
| -l'adresse
| -le login
| -le mot de passe
| exite-il une procédure vb existante ou faire référence à quelle
| bibliothèque dans VB
| Merci bien
| Pierre


Qu'appelles tu une "requête en fichier texte" ?
tu veux lier une table "fichier texte" à une base access locale
et interroger les données de ce fichier situé dans un dossier ftp ?

--
à+
Arnaud
--------------------------------------------------
Conseils d'utilisation, sites recommandés :
http://users.skynet.be/mpfa/
Access Memorandum - http://memoaccess.free.fr
--------------------------------------------------
Avatar
Pierre Bunoz
merci de la réponse
en fait je voudrais
- envoyer (upload) les données d'une table en tant que fichier texte dans
un dossier ftp
ce fichier sera traité en php mysql sur le site (cette partie ne me concerne
pas), ensuite je voudrais
- télécharger (dowload) ce fichier qui est dans le même dossier ftp et
l'importer dans une autre table de ma base
après je compare mon envoi avec le retour sur Etat

autre question : peut-on sur access 2000 avoir une connexion en dynamique
avec une base mysql sur un serveur ?

Merci bien


"Anor" a écrit dans le message de news:

Bonjour

Pierre Bunoz a confié :
| bonjour
| je voudrais envoyer une requête (en fichier texte) sur un site ftp
| pour lequel je connais
| -l'adresse
| -le login
| -le mot de passe
| exite-il une procédure vb existante ou faire référence à quelle
| bibliothèque dans VB
| Merci bien
| Pierre


Qu'appelles tu une "requête en fichier texte" ?
tu veux lier une table "fichier texte" à une base access locale
et interroger les données de ce fichier situé dans un dossier ftp ?

--
à+
Arnaud
--------------------------------------------------
Conseils d'utilisation, sites recommandés :
http://users.skynet.be/mpfa/
Access Memorandum - http://memoaccess.free.fr
--------------------------------------------------




Avatar
Anor
Bonjour Pierre,


Pierre Bunoz a confié :
| merci de la réponse
| en fait je voudrais
| - envoyer (upload) les données d'une table en tant que fichier
| texte dans un dossier ftp
| ce fichier sera traité en php mysql sur le site (cette partie ne me
| concerne pas), ensuite je voudrais
| - télécharger (dowload) ce fichier qui est dans le même dossier ftp
| et l'importer dans une autre table de ma base
| après je compare mon envoi avec le retour sur Etat
|
| autre question : peut-on sur access 2000 avoir une connexion en
| dynamique avec une base mysql sur un serveur ?
|
| Merci bien
|

ok je comprends mieux le besoin.
Essaye avec les API qui vont bien ;-)
(désolé pour les coupures, code pas encore mis en forme)

Option Compare Database
Option Explicit

Public Const NO_ERROR = 0
Public Const FILE_ATTRIBUTE_READONLY = &H1
Public Const FILE_ATTRIBUTE_HIDDEN = &H2
Public Const FILE_ATTRIBUTE_SYSTEM = &H4
Public Const FILE_ATTRIBUTE_DIRECTORY = &H10
Public Const FILE_ATTRIBUTE_ARCHIVE = &H20
Public Const FILE_ATTRIBUTE_NORMAL = &H80
Public Const FILE_ATTRIBUTE_TEMPORARY = &H100
Public Const FILE_ATTRIBUTE_COMPRESSED = &H800
Public Const FILE_ATTRIBUTE_OFFLINE = &H1000
Public Const FORMAT_MESSAGE_FROM_HMODULE = &H800
Public Const INTERNET_INVALID_PORT_NUMBER = 0
Public Const ERROR_NO_MORE_FILES = 18

Const FTP_TRANSFER_TYPE_UNKNOWN = &H0
Const FTP_TRANSFER_TYPE_ASCII = &H1
Const FTP_TRANSFER_TYPE_BINARY = &H2
Const INTERNET_DEFAULT_FTP_PORT = 21
Const INTERNET_SERVICE_FTP = 1
Const INTERNET_FLAG_RELOAD = &H80000000
Const INTERNET_FLAG_PASSIVE = &H8000000
Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_OPEN_TYPE_PROXY = 3
Const INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4
Const MAX_PATH = 260
Const PassiveConnection As Boolean = True

Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type

Public Declare Function InternetCloseHandle Lib "wininet" (ByRef hInet As Long) As Long
Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal
hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal
sUserName As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long,
ByVal lContext As Long) As Long
Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As
String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String,
ByVal lFlags As Long) As Long
Public Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal
hInternet As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength
As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Public Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFtpSession As Long, ByVal
strBuffer As String, ByVal lngLengthBuffer As Long, lngBytesRead As Long) As Boolean
Public Declare Function InternetWriteFile Lib "wininet.dll" (ByVal hFile As Long, ByRef sBuffer
As Byte, ByVal lNumBytesToWrite As Long, dwNumberOfBytesWritten As Long) As Integer
Public Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias "FtpSetCurrentDirectoryA"
(ByVal hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
Public Declare Function FtpGetCurrentDirectory Lib "wininet.dll" Alias "FtpGetCurrentDirectoryA"
(ByVal hFtpSession As Long, ByVal lpszCurrentDirectory As String, lpdwCurrentDirectory As Long)
As Long
Public Declare Function FtpCreateDirectory Lib "wininet.dll" Alias "FtpCreateDirectoryA" (ByVal
hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
Public Declare Function FtpRemoveDirectory Lib "wininet.dll" Alias "FtpRemoveDirectoryA" (ByVal
hFtpSession As Long, ByVal lpszDirectory As String) As Boolean
Public Declare Function FTPDeleteFile Lib "wininet.dll" Alias "FtpDeleteFileA" (ByVal
hFtpSession As Long, ByVal lpszFileName As String) As Boolean
Public Declare Function FtpRenameFile Lib "wininet.dll" Alias "FtpRenameFileA" (ByVal
hFtpSession As Long, ByVal lpszExisting As String, ByVal lpszNew As String) As Boolean
Public Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" (ByVal hConnect As
Long, ByVal lpszRemoteFile As String, ByVal lpszNewFile As String, ByVal fFailIfExists As Long,
ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, ByRef dwContext As Long) As Boolean
Public Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hConnect As
Long, ByVal lpszLocalFile As String, ByVal lpszNewRemoteFile As String, ByVal dwFlags As Long,
ByVal dwContext As Long) As Boolean
Public Declare Function FtpOpenFile Lib "wininet.dll" Alias "FtpOpenFileA" (ByVal hFtpSession As
Long, ByVal sBuff As String, ByVal Access As Long, ByVal Flags As Long, ByVal Context As Long)
As Long
Public Declare Function InternetGetLastResponseInfo Lib "wininet.dll" Alias
"InternetGetLastResponseInfoA" (lpdwError As Long, ByVal lpszBuffer As String, lpdwBufferLength
As Long) As Boolean
Public Declare Function FtpFindFirstFile Lib "wininet.dll" Alias "FtpFindFirstFileA" (ByVal
hFtpSession As Long, ByVal lpszSearchFile As String, lpFindFileData As WIN32_FIND_DATA, ByVal
dwFlags As Long, ByVal dwContent As Long) As Long
Public Declare Function InternetFindNextFile Lib "wininet.dll" Alias "InternetFindNextFileA"
(ByVal hFind As Long, lpvFindData As WIN32_FIND_DATA) As Long

Dim hConnection As Long
Dim hOpen As Long
Dim sOrgPath As String
Dim pData As WIN32_FIND_DATA
Dim hFile As Long
Dim hFind As Long
Dim lRet As Long


Sub Upload()
hOpen = InternetOpen("TEST", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
hConnection = InternetConnect(hOpen, "ftp.domaine.com", INTERNET_DEFAULT_FTP_PORT, "login",
"password", INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)
FtpPutFile hConnection, "C:fichier.txt", "fichier.txt", FTP_TRANSFER_TYPE_UNKNOWN, 0
InternetCloseHandle hConnection
InternetCloseHandle hOpen
End Sub


Sub Download()
hOpen = InternetOpen("TEST", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
hConnection = InternetConnect(hOpen, "ftp.domaine.com", INTERNET_DEFAULT_FTP_PORT, "login",
"password", INTERNET_SERVICE_FTP, IIf(PassiveConnection, INTERNET_FLAG_PASSIVE, 0), 0)
FtpGetFile hConnection, "fichier.txt", "c:fichier.txt", False, 0,
FTP_TRANSFER_TYPE_UNKNOWN, 0
FTPDeleteFile hConnection, "fichier.txt"
InternetCloseHandle hConnection
InternetCloseHandle hOpen
End Sub

Function fReadInURL(strURL As String) As String
Dim sBuffer As String
sBuffer = Space(1000)
hOpen = InternetOpen("HTTPTest", 1, vbNullString, vbNullString, 0)
hFile = InternetOpenUrl(hOpen, strURL, vbNullString, ByVal 0&, INTERNET_FLAG_RELOAD, ByVal
0&)
InternetReadFile hFile, sBuffer, Len(sBuffer), lRet
InternetCloseHandle hFile
InternetCloseHandle hOpen
fReadInURL = sBuffer
End Function


--
à+
Arnaud
--------------------------------------------------
Conseils d'utilisation, sites recommandés :
http://users.skynet.be/mpfa/
Access Memorandum - http://memoaccess.free.fr
--------------------------------------------------