1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
Private Sub cmdUpload_Click()
'Code à utiliser pour uploader un fichier
'text2 => nom de l'user ( anonyme qlq a une idée ? )
'text3 => password de l'user
'text1 => nom du serveur ( ftp.bidulechouete.fr )
'text4 => fichier source
'text5 => fichier de destination
'Procedure :
' With Inet1
' .URL = ("ftp://" & text2 & ":" & text3 & "@" & text1)
' .Execute , ("PUT " & Text4 & " " & Text5)
' End With
' A besoin de la reference : Microsoft Internet Transfert Controls 6.0
Dim fichToUpload As String
Dim fichToRename As String
Dim Clef As String
Dim RepDestination As String
Dim i As Byte
Dim tmpString As String
Dim ctl As Object
On Error GoTo Err_cmd
If MsgBox("Voulez-vous envoyer les fichiers sur votre FTP ?", vbQuestion + vbYesNo) = vbYes Then
With Me.Inet1
'.Protocol = icFTP 'declaration protocole
.URL = "monsite.free.fr"
.UserName = "nomUtilisateur"
.Password = "motdepasse"
'Fichier à Uploader
fichToUpload = "d:/dev/dev_FTP/test.log"
If Dir(fichToUpload) = "" Thef
MsgBox fichToUpload & vbCrLf & " : fichier introuvable !", vbExclamation
.Execute , "CLOSE" ' Ferme la connexion.
Do Until .StillExecuting = False 'boucle pendant le traitement de Inet
DoEvents
Loop
MsgBox "Reconfigurez SVP", vbInformation
Exit Sub
End If
fichToRename = "fichierRenommé.txt"
If InStr(1, fichToUpload, " ") <> 0 Then
'y a espace dans le chemin, faut doubler les ""
fichToUpload = """" & fichToUpload & """"
End If
If InStr(1, fichToRename, " ") <> 0 Then
'y a espace dans le chemin, faut doubler les ""
fichToRename = """ & fichToRename & """
End If
'RepDestination = cr.JustDécrypter(GetSetting("FTP - Upload backup", "FTP", "Répertoire de destination"), Clef)
RepDestination = "Dir1"
tmpString = fichToUpload & " /" & RepDestination & "/" & fichToRename
Debug.Print "tmpString: " & tmpString
.Execute , "PUT " & tmpString
Do Until .StillExecuting = False 'boucle pendant le traitement de inet
DoEvents
Loop
.Execute , "CLOSE" 'ferme la connexion.
Do Until .StillExecuting = False 'boucle pendant le traitement de inet
DoEvents
Loop
End With
MsgBox "Transfert réussi ;-)"
End If
Exit_cmd:
Exit Sub
Err_cmd:
MsgBox Err.Number & vbCr & Err.Description
Resume Exit_cmd
End Sub |
Partager