xGardian Posted November 15, 2015 Share Posted November 15, 2015 So I've been working on a project about a questionnaire which will upload the results(they are written in ini file) to a FTP server...So im using a code from a example$server = 'nope.avi' $username = 'nope.avi' $pass = 'nope.avi' $Open = _FTPOpen('MyFTP Control') $Conn = _FTPConnect($Open, $server, $username, $pass) _FtpPutFile($Conn, 'Results.ini', '/public_html/Results.ini') _FTPClose($Open) It worked when i first tried,but when i put it in a function,it wont work o.OThanks for watching. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 15, 2015 Developers Share Posted November 15, 2015 You are not using the standard provided UDF's as that UDF name is _FTP_Open()?Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
xGardian Posted November 15, 2015 Author Share Posted November 15, 2015 It won't work for me.Tried same $Open = _FTP_Open('MyFTP Control') $Conn = _FTP_Connect($Open, $server, $username, $pass) _FTP_FilePut($Conn, 'Results.ini', '/public_html/Results.ini') _FTP_Close($Open) Exit Link to comment Share on other sites More sharing options...
Developers Jos Posted November 15, 2015 Developers Share Posted November 15, 2015 Are you seriously thinking we can help when this is all info you provide? Do some error checking after each function to see which has problems and be clear on what you need help with.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
xGardian Posted November 15, 2015 Author Share Posted November 15, 2015 (edited) When I use the code to a empty project,It works,however when i put it to a full-source-code it won't workI'm making a questionnaire for a project,it writes the answers to a ini,and the ini shall be sent to the ftp.A sample from code ... if GUICtrlRead($Radio57) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση12","18-20") EndIf if GUICtrlRead($Radio58) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση12","21-23") EndIf if GUICtrlRead($Radio59) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση12",">24") EndIf _FtpPutFile($Conn, 'Results.ini', '/public_html/Results.ini') _FTPClose($Open)EndFunc But it won't work.I tried the standard $server = 'nope.avi' $username = 'nope.avi' $pass = 'nope.avi' $Open = _FTP_Open('MyFTP Control') $Conn = _FTP_Connect($Open, $server, $username, $pass) _FTP_FilePut($Conn, 'Results.ini', '/public_html/Results.ini') _FTP_Close($Open) but it won't work either... Edited November 15, 2015 by xGardian Link to comment Share on other sites More sharing options...
AutoBert Posted November 16, 2015 Share Posted November 16, 2015 Try this ecample script:expandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <FTPEx.au3> Opt('MustDeclareVars', 1) _example() Func _example() Local $s_ServerName = '127.0.0.1' ;dieser Server existiert nicht Local $s_Username = "Bert" Local $s_Password = "Test" Local $s_LocalFile = @ScriptDir & "\FTP_FilePut.au3" Local $s_RemoteFile = "/AutoIt3.My/FTP_FilePut.au3" Local $i_Passive = 0 Local $l_InternetSession, $l_FTPSession, $errOpen, $errFTP If Not FileExists($s_LocalFile) Then ConsoleWrite('Local File not found' & @CRLF) Exit EndIf $l_InternetSession = _FTP_Open('AuoItZilla') ;Öffnet eine FTP Sitzung $errOpen = @error If Not @error Then ConsoleWrite("Internet-Session opened" & @CRLF) $l_FTPSession = _FTP_Connect($l_InternetSession, $s_ServerName, $s_Username, $s_Password, $i_Passive) ;Verbindet zu einem FTP Server $errFTP = @error If Not @error Then ConsoleWrite("connected to " & $s_ServerName & @CRLF) If _FTP_FilePut($l_FTPSession, $s_LocalFile, $s_RemoteFile) Then ConsoleWrite("Upload: successful" & @CRLF) Else ConsoleWrite("Upload: not successful " & " " & @error & @CRLF) ConsoleWrite("Check all Folders in Remotepath, they must exist before uploading!" & @CRLF) EndIf Else MsgBox(0, "Connect", "not successful") ConsoleWrite("Connect: " & " " & $errFTP & @CRLF) EndIf Else MsgBox(0, "Open", "not successful") ConsoleWrite("Open " & " " & $errOpen & @CRLF) EndIf _FTP_Close($l_FTPSession) ;schliesst die FTP-Sitzung _FTP_Close($l_InternetSession) ;schliesst die Internet-Sitzung EndFunc ;==>_exampleif also not working post the consolemessages Link to comment Share on other sites More sharing options...
xGardian Posted November 16, 2015 Author Share Posted November 16, 2015 (edited) @AutoBertThanks a lot ,it worked but when I put the code on the project,with the results ini im making ,it says "Check all Folders in Remotepath, they must exist before uploading!"It just won't upload it :c expandcollapse popupFunc _results() FileOpen("Results.ini", $FO_UTF16_LE + $FO_OVERWRITE) If GUICtrlRead($Radio1) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση1","airtickets.gr") EndIf if GUICtrlRead($Radio2) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση1","travelplan.gr") EndIf if GUICtrlRead($Radio3) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση1","Αλλο") EndIf if GUICtrlRead($Radio4) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση2","Διαφωνω απολυτα") EndIf if GUICtrlRead($Radio5) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση2","Διαφωνω λιγο") EndIf if GUICtrlRead($Radio6) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση2","Δεν διαφωνω / Ουτε συμφωνω") EndIf if GUICtrlRead($radio7) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση2","Συμφωνω λιγο") EndIf if GUICtrlRead($radio8) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση2","Συμφωνω απολυτα") EndIf if GUICtrlRead($radio9 )= 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση3","ναι") EndIf if GUICtrlRead($Radio10) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση3","οχι") EndIf Sleep(200) if GUICtrlRead($radio9) = 1 Then if GUICtrlRead($Radio11) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση3α","Internet") EndIf if GUICtrlRead($Radio12) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση3α","Φιλου/Γνωστου/Συγγενη") EndIf if GUICtrlRead($Radio13) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση3α","Διαφημηση") EndIf if GUICtrlRead($Radio14) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση3α","Αλλο") EndIf EndIf Sleep(200) If GUICtrlRead($Radio15) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση4","Διαφωνω απολυτα") EndIf if GUICtrlRead($Radio16) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση4","Διαφωνω λιγο") EndIf if GUICtrlRead($Radio17) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση4","Δεν διαφωνω / Ουτε συμφωνω") EndIf if GUICtrlRead($Radio18) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση4","Συμφωνω λιγο") EndIf if GUICtrlRead($Radio19) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση4","Συμφωνω απολυτα") EndIf if guictrlread($Radio20) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση5","ναι") EndIf Sleep(200) if GUICtrlRead($radio21) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση5","οχι") EndIf if GUICtrlRead($Radio20) = 1 Then if GUICtrlRead($Radio22) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση5α","Διαφωνω Απολυτα") EndIf if GUICtrlRead($Radio23) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση5α","Διαφωνω λιγο") EndIf Sleep(500) if GUICtrlRead($Radio24) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση5α","Δεν διαφωνω/ Ουτε συμφωνω") EndIf if GUICtrlRead($radio25) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση5α","Συμφωνω λιγο") EndIf if GUICtrlRead($Radio26) = 1 Then IniWrite("Results.ini","Αποτελεσματα",'Ερωτηση5α',"Συμφωνω απολυτα") EndIf EndIf if GUICtrlRead($radio27) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση6","Διαφωνω απολυτα") EndIf Sleep(300) if GUICtrlRead($radio28) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση6","Διαφωνω λιγο") EndIf if GUICtrlRead($Radio29) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση6","Δεν διαφωνω / Ουτε συμφωνω") EndIf if GUICtrlRead($Radio30 ) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση6","Συμφωνω λιγο") EndIf if GUICtrlRead($Radio31) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση6","Συμφωνω απολυτα") EndIf if GUICtrlRead($Radio32) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση7","ναι") EndIf if GUICtrlRead($Radio33) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση7","οχι") EndIf Sleep(200) if GUICtrlRead($Radio32) = 1 Then if GUICtrlRead($Radio34) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση7α","Δευτερολεπτα") EndIf if GUICtrlRead($Radio35) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση7α","Λεπτα") EndIf if GUICtrlRead($Radio36) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση7α","ωρες") EndIf if GUICtrlRead($Radio37) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση7α","μερες") EndIf EndIf Sleep(200) if GUICtrlRead($Radio38) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση8","Διαφωνω απολυτα") EndIf if GUICtrlRead($Radio39) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση8","Διαφωνω λιγο") EndIf if GUICtrlRead($Radio40) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση8","Δεν διαφωνω / Ουτε συμφωνω") EndIf if GUICtrlRead($Radio41) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση8","Συμφωνω λιγο") EndIf if GUICtrlRead($Radio42) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση8","Συμφωνω απολυτα") EndIf if GUICtrlRead($Radio43) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση9","Διαφωνω απολυτα") EndIf if GUICtrlRead($Radio44) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση9","Διαφωνω λιγο") EndIf if GUICtrlRead($Radio45) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση9","Δεν διαφωνω / Ουτε συμφωνω") EndIf if GUICtrlRead($Radio46) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση9","Συμφωνω λιγο") EndIf if GUICtrlRead($Radio47) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση9","Συμφωνω απολυτα") EndIf Sleep(300) if GUICtrlRead($Radio48) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση10","ναι") EndIf if GUICtrlRead($Radio49) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση10","οχι") EndIf if GUICtrlRead($radio50) = 1 Then if GUICtrlRead($Radio48) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση10α","Διαφωνω απολυτα") EndIf if GUICtrlRead($radio51) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση10α","Διαφωνω λιγο") EndIf If GUICtrlRead($radio52) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση10α","Δεν διαφωνω / Ουτε συφμωνω") EndIf Sleep(200) if GUICtrlRead($radio53) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση10α","Συμφωνω λιγο") EndIf if GUICtrlRead($Radio54) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση10α","Συμφωνω απολυτα") EndIf EndIf if GUICtrlRead($Radio55) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση11","Ανδρας") EndIf if GUICtrlRead($Radio56) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση11","Γυναικα") EndIf Sleep(100) if GUICtrlRead($Radio57) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση12","18-20") EndIf if GUICtrlRead($Radio58) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση12","21-23") EndIf if GUICtrlRead($Radio59) = 1 Then IniWrite("Results.ini","Αποτελεσματα","Ερωτηση12",">24") EndIf FileClose("Results.ini") Sleep(500) _example() Exit EndFunc Func _example() Local $s_ServerName = 'servert' ;dieser Server existiert nicht Local $s_Username = "myusr" Local $s_Password = "mypw" Local $s_LocalFile = @ScriptDir & "Results.ini"" Local $s_RemoteFile = "/public_html/Results.ini" Local $i_Passive = 0 Local $l_InternetSession, $l_FTPSession, $errOpen, $errFTP If Not FileExists($s_LocalFile) Then ConsoleWrite('Local File not found' & @CRLF) Exit EndIf $l_InternetSession = _FTP_Open('AuoItZilla') ;Öffnet eine FTP Sitzung $errOpen = @error If Not @error Then ConsoleWrite("Internet-Session opened" & @CRLF) $l_FTPSession = _FTP_Connect($l_InternetSession, $s_ServerName, $s_Username, $s_Password, $i_Passive) ;Verbindet zu einem FTP Server $errFTP = @error If Not @error Then ConsoleWrite("connected to " & $s_ServerName & @CRLF) If _FTP_FilePut($l_FTPSession, $s_LocalFile, $s_RemoteFile) Then ConsoleWrite("Upload: successful" & @CRLF) Else ConsoleWrite("Upload: not successful " & " " & @error & @CRLF) ConsoleWrite("Check all Folders in Remotepath, they must exist before uploading!" & @CRLF) EndIf Else MsgBox(0, "Connect", "not successful") ConsoleWrite("Connect: " & " " & $errFTP & @CRLF) EndIf Else MsgBox(0, "Open", "not successful") ConsoleWrite("Open " & " " & $errOpen & @CRLF) EndIf _FTP_Close($l_FTPSession) ;schliesst die FTP-Sitzung _FTP_Close($l_InternetSession) ;schliesst die Internet-Sitzung EndFunc ;==>_example the full code which it will be bugging.It upload any other file i put Edited November 16, 2015 by xGardian Link to comment Share on other sites More sharing options...
Developers Jos Posted November 16, 2015 Developers Share Posted November 16, 2015 Not so sure UTF16 is supported in the Standard Windows INI calls we use.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
xGardian Posted November 16, 2015 Author Share Posted November 16, 2015 (edited) Well it writes the results in the ini , but it gets bug on uploading.But as i said when i use the code on a empty project,it works. Edit: aw it's working now..something with fileclose was the problem.Thanks anyone who answered Edited November 16, 2015 by xGardian Link to comment Share on other sites More sharing options...
xGardian Posted November 16, 2015 Author Share Posted November 16, 2015 (edited) Hey again.I wanna ask one more question.This programm is gonna be shared to many people,and i dont wanna everyone have the same ini name : Results.ini ,because it will be overwritted on server.What can i do to avoid it?Like giving random name or taking computer's time as the ini name?Tried to use Random but in upload function it can't find thefile Edited November 16, 2015 by xGardian Link to comment Share on other sites More sharing options...
AutoBert Posted November 17, 2015 Share Posted November 17, 2015 Use the @AppDataDir (Path to current user's Roaming Application Data) Link to comment Share on other sites More sharing options...
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