Envoie fichier sur ftp par api

cs_moi4975 Messages postés 109 Date d'inscription lundi 27 juin 2005 Statut Membre Dernière intervention 17 juillet 2007 - 10 mars 2006 à 22:23
cs_Jack Messages postés 14006 Date d'inscription samedi 29 décembre 2001 Statut Modérateur Dernière intervention 28 août 2015 - 11 mars 2006 à 00:30
Voila je voudrais envoyer un fichier texte sur un ftp mais je n'y arrive pas; le fichier n'arrive jamis sur mon ftp.
Pouvez-vous jetter un coup d'oeil à mon code pour me dire ce qui cloche ??

Merci de m'aider .... Voila mon code :

Private 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

Private 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

Private Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" (ByVal hFtpSession As Long, ByVal lpszLocalFile As String, ByVal lpszRemoteFile As String, ByVal dwFlags As Long, ByVal dwContext As Long) As Boolean

Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer

Private Sub Command2_Click()
Dim hConnection As Long
Dim hOpen As Long


hOpen = InternetOpen(App.Title, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)


hConnection = InternetConnect(hOpen, "Mon ftp",21, "Mon Log in", "Mon moydepasse", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0)

FtpPutFile hConnection, "C:\Essai.txt","Essai.txt",
FTP_TRANSFERT_TYPE_BINARY, 0

InternetCloseHandle hConnection
InternetCloseHandle hOpen
End Sub

2 réponses

cs_Jack Messages postés 14006 Date d'inscription samedi 29 décembre 2001 Statut Modérateur Dernière intervention 28 août 2015 79
11 mars 2006 à 00:18
Salut
Je ne vois rien de flagrant.
Peut-être serait plus judicieux d'utiliser un transfert de type ASCII et non Binary:
FTP_TRANSFER_TYPE_ASCII = &H1

Sinon, je te propose du tout fait au travers de cette classe : clique ici

Vala
Jack, MVP VB
NB : Je ne répondrai pas aux messages privés

Champion du monde de boule de cristal - 2005
Le savoir est la seule matière qui s'accro
0
cs_Jack Messages postés 14006 Date d'inscription samedi 29 décembre 2001 Statut Modérateur Dernière intervention 28 août 2015 79
11 mars 2006 à 00:30
ou celle-ci, plus complète clique ici
0
Rejoignez-nous