kobustimmer
Gebruiker
- Lid geworden
- 16 dec 2013
- Berichten
- 9
Hallo
Wie kan mij helpen.
ik probeer een file te uploaden naar mijn website.
ben nu twee weken aan het zoeken heb wel het een en ander gevonden.
waar onder het volgende script maar loop vast bij het uitvoeren.
na commando 150 gebeurt er niets meer.
dit krijg ik te zien bij het uitvoeren :
ftp> !REM upload .jpg file
ftp> open ftp.xxxxxxxx.nl 21
verbonden met ftp.xxxxxxxx.nl.
220 Microsoft FTP Service
ftp> user xxxxxxxx xxxxxxx
331 pasword required
230 User logged in.
ftp> cd httpdocs/testdirectory/
250 CWD command succesful.
ftp> binary
200 Type set to I.
ftp> put F:\test.jpg
200 PORT command successful
150 Opening BINARY mode data connection.
Wie kan mij helpen.
ik probeer een file te uploaden naar mijn website.
ben nu twee weken aan het zoeken heb wel het een en ander gevonden.
waar onder het volgende script maar loop vast bij het uitvoeren.
na commando 150 gebeurt er niets meer.
dit krijg ik te zien bij het uitvoeren :
ftp> !REM upload .jpg file
ftp> open ftp.xxxxxxxx.nl 21
verbonden met ftp.xxxxxxxx.nl.
220 Microsoft FTP Service
ftp> user xxxxxxxx xxxxxxx
331 pasword required
230 User logged in.
ftp> cd httpdocs/testdirectory/
250 CWD command succesful.
ftp> binary
200 Type set to I.
ftp> put F:\test.jpg
200 PORT command successful
150 Opening BINARY mode data connection.
Code:
Public Sub Ftp_Upload_File()
Const cFTPServer As String = "ftp.xxxxxxx.nl" 'hier staat mijn website.
Const cFTPPort = 21
Const cFTPCommandsFile As String = "FTP_commands.txt"
Dim inputValue As Variant
Dim FTPusername As String, FTPpassword As String
Dim filenum As Integer
Dim FTPcommand As String
Dim wsh As Object
filenum = FreeFile
Open cFTPCommandsFile For Output As #filenum
Print #filenum, "!REM upload .jpg file" 'Use !REM for comments with a Windows ftp server
Print #filenum, "open " & cFTPServer & " " & cFTPPort
Print #filenum, "user " & "xxxxxxxx" & " " & "xxxxxxxx"
''Print #filenum, "user " & FTPusername & " " & FTPpassword
Print #filenum, "cd httpdocs/testdirectory/"
Print #filenum, "binary"
Print #filenum, "put " & QQ(ThisWorkbook.Path & "\test.jpg")
''Print #filenum, "put " & QQ(ThisWorkbook.Path & "\test.jpg")
Close #filenum
'Construct ftp command line, specifying the file containing FTP commands. The -n parameter suppresses auto-login
'upon initial connection because we want to use the username and password specified in the command file
FTPcommand = "ftp -i -n -s:" & QQ(cFTPCommandsFile)
CreateObject("WScript.Shell").Run Command:=FTPcommand, WindowStyle:=1, waitonreturn:=True
'Delete the ftp commands file so that the username and password are not left lying around
Kill cFTPCommandsFile
MsgBox "Finished"
End Sub
Private Function QQ(text As String) As String
QQ = Chr(34) & text & Chr(34)
End Function