SgtRhoruns 0 Posted July 20, 2010 Or any other FTP function for that matter, besides _FTP_Open, _FTP_Connect, and _FTP_Close. All other functions seem to fail for unknown reasons. I'd like to find out why these functions will not respond. I've monitored the server log, and it does indeed connect, but makes NO attempt to upload or communicate past connecting and successfully authenticating. I'm on Windows 7 with all updates applied, and the latest version of AutoIt, if that makes a difference. This is part of a much larger script, but here's the code that's essentially being used: #include <FTPEx.au3> $ftp_server = "127.0.0.1" $ftp_username = "user" $ftp_password = "pass" $ftp_port = "21" Global $ftp_session $ftp_session = _FTP_Open("image_session") $FTP_CS = _FTP_Connect($ftp_session, $ftp_server, $ftp_username, $ftp_password, $ftp_port, 1) If $FTP_CS = 0 Then MsgBox(0, "3", "Could not connect to server. It may be under maintenance.", 3) Else MsgBox(0, "3", "Client connected! Session = " & $ftp_session, 3) EndIf $FTP_PF = _FTP_FilePut($ftp_session, "test.txt", "test.txt" ) ; <--- Script always fails here. I've tried other functions such as _FTP_FileGetSize, fails or equals 0. If $FTP_PF = 0 Then MsgBox(0, "3", "Could not upload file.", 3) EndIf _FTP_Close($ftp_session) Share this post Link to post Share on other sites
SgtRhoruns 0 Posted July 20, 2010 (edited) Update:I performed a _WinAPI_GetLastError() just after _FTP_FilePut(), and I get the error code 12018.After searching the MSDN for an explanation, I found this:ERROR_INTERNET_INCORRECT_HANDLE_TYPE12018The type of handle supplied is incorrect for this operation.I'm not entirely sure what this means, but I would guess that the _FTP_Open() function isn't returning a valid handle to be used with _FTP_FilePut(). Any ideas? Edited July 20, 2010 by SgtRhoruns Share this post Link to post Share on other sites
SgtRhoruns 0 Posted July 20, 2010 (edited) Oh my god, I am a complete moron. I guess this what you get for staying up all night trying to solve the issue rather than sleeping on it. Here's the error I made:$ftp_session = _FTP_Open("image_session") $FTP_CS = _FTP_Connect($ftp_session, $ftp_server, $ftp_username, $ftp_password, $ftp_port, 1) ~ | | | ~ $FTP_PF = _FTP_FilePut($ftp_session, "test.txt", "test.txt" )I was using the value returned from _FTP_Open() instead of the handle from _FTP_Connect(). I took the value returned from _FTP_Connect() and plugged it in to _FTP_FilePut(), now it works perfectly, yay! Here's the corrected code:$ftp_session = _FTP_Open("image_session") $FTP_CS = _FTP_Connect($ftp_session, $ftp_server, $ftp_username, $ftp_password, $ftp_port, 1) ~ | | | ~ $FTP_PF = _FTP_FilePut($FTP_CS, "test.txt", "test.txt" )This code is actually a few years old and I wanted to update it to work with the latest FTP developments, but I got lazy and didn't make all the necessary tweaks to my variables. For anyone with a similar (dumb) issue, I hope this helped. Sorry for wasting anyone's time! Edited July 20, 2010 by SgtRhoruns Share this post Link to post Share on other sites