PerryRaptor Posted January 12, 2005 Posted January 12, 2005 I'm using the .103 version and have looked through the help file. I've tried DriveMapAdd() and that didn't work. Any Ideas? I would like to copy a created file to an FTP server
SumTingWong Posted January 12, 2005 Posted January 12, 2005 I'm using the .103 version and have looked through the help file. I've tried DriveMapAdd() and that didn't work.Any Ideas?I would like to copy a created file to an FTP server<{POST_SNAPBACK}>Here's a UDF if you want to do it without using an external ftp client.You need the latest beta.expandcollapse popup; Access types for InternetOpen() Global $INTERNET_OPEN_TYPE_PRECONFIG = 0 Global $INTERNET_OPEN_TYPE_DIRECT = 1 Global $INTERNET_OPEN_TYPE_PROXY = 3 Global $INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4 ; Service types for InternetConnect() Global $INTERNET_SERVICE_FTP = 1 Global $INTERNET_SERVICE_GOPHER = 2 Global $INTERNET_SERVICE_HTTP = 3 Global $INTERNET_DEFAULT_FTP_PORT = 21 Global $INTERNET_FLAG_ASYNC = 0x10000000 Global $INTERNET_FLAG_PASSIVE = 0x08000000 Global $FTP_TRANSFER_TYPE_UNKNOWN = 0x00000000 Global $FTP_TRANSFER_TYPE_ASCII = 0x00000001 Global $FTP_TRANSFER_TYPE_BINARY = 0x00000002 Dim $nRetCode ; Example $nRetCode = _FtpPutFile("Your ftp server", _ "your ftp user name", _ "your ftp password", _ "c:\some local file.txt", _ "remote directory\some local file.txt", _ $FTP_TRANSFER_TYPE_ASCII) MsgBox(4096,'debug line ~23' , '$nRetCode:' & @lf & $nRetCode);### Debug MSGBOX Func _FtpPutFile($sServer, $sUserName, $sPassword, $sLocalFile, $sRemoteFile, $nType = 0, $nPassive = 1) Local $hWininet Local $hInternet Local $hConnect Local $aDllRet Local $nRet = 0 $hWininet = DllOpen("wininet.dll") If $hWininet = -1 Then Return $nRet $aDllRet = DllCall($hWininet, "ptr", "InternetOpen", _ "str", "AutoITFTPUDF", _ "long", $INTERNET_OPEN_TYPE_DIRECT, _ "int", 0, _ "int", 0, _ "long", $INTERNET_FLAG_ASYNC) If Not @error And $aDllRet[0] <> 0 Then $hInternet = $aDllRet[0] If $nPassive Then $nPassive = $INTERNET_FLAG_PASSIVE Else $nPassive = 0 EndIf $aDllRet = DllCall($hWininet, "ptr", "InternetConnect", _ "ptr", $hInternet, _ "str", $sServer, _ "long", $INTERNET_DEFAULT_FTP_PORT, _ "str", $sUserName, _ "str", $sPassword, _ "long", $INTERNET_SERVICE_FTP, _ "long", $nPassive, _ "int", 0) If Not @error And $aDllRet[0] <> 0 Then $hConnect = $aDllRet[0] $aDllRet = DllCall($hWininet, "int", "FtpPutFile", _ "ptr", $hConnect, _ "str", $sLocalFile, _ "str", $sRemoteFile, _ "long", $nType, _ "int", 0) If Not @error Or $aDllRet[0] <> 0 Then $nRet = -1 Else $aDllRet = DllCall("kernel32.dll", "long", "GetLastError") If Not @error Then $nRet = $aDllRet[0] EndIf ; Send QUIT command to ftp server $aDllRet = DllCall($hWininet, "int", "FtpCommand", _ "ptr", $hConnect, _ "int", 0, _ "long", $FTP_TRANSFER_TYPE_ASCII, _ "str", "QUIT", _ "int", 0, _ "int", 0) DllCall($hWininet, "int", "InternetCloseHandle", "ptr", $hConnect) EndIf DllCall($hWininet, "int", "InternetCloseHandle", "ptr", $hInternet) EndIf DllClose($hWininet) Return $nRet EndFunc
PerryRaptor Posted January 12, 2005 Author Posted January 12, 2005 Super UDF...Like the Kernell32 call to get the last error, if any. I guess everything is going the way of DLLCall()...PacMan's UDF would be a good choice for the help file.
Guest phoenixfire425 Posted April 5, 2005 Posted April 5, 2005 iS THERE A WAY TO MAKE THIS SCRIPT CALL A WILDCARD?? FOR THE FILE? EX. *.ZIP???
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now