Jump to content
Sign in to follow this  
RickB75

I need a little help with FTP, My network Places

Recommended Posts

RickB75

Guys,

Here's my issue. I have PDF's that I upload each day to my server and I'm trying to set up this FTP so that the script can handle it. I've read other post in this and other forums about how to write an ftp script and I'm still running into issues. This is what I've done so far.

Using a FTP script, I can get a message in the Debug box that includes a return of letters and numbers. I think it is connecting. Sometimes when I change the server address as a test, It will throw back a "0" so I think I'm connecting the right way. The script doesn't try to upload the file though. it runs the script in less than 2 secs.

$host = "ftp.MyWebsite.com"      ; Hostname of the webserver (Can be a domain name or an IP)
$user = "Username"       ; FTP Username
$pass = "Password"       ; FTP Password
$folder = "/targetfolder"        ; This is the folder where your files will upload to
$open = _FTP_Open("Myftp")
     $conn = _FTP_Connect($open, $host, $user, $pass,0,0)
     MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '_FTP_Connect($open, $host, $user,
$pass,0,0)' & @lf & @lf & 'Return:' & @lf & _FTP_Connect($open, $host, $user, $pass,0,0)) ;### Debug MSGBOX
     _FTP_FilePut($conn, $myFile,$folder,0,0)
     _FTP_Close($open)

I'm running a couple of external FTP programs. Filezilla which connects perfect to this site and another one that is spotty (sometimes it will connect and other times will throw me the middle finger). The latter of the two has a built in scheduler and that is the only reason I'm using it.

I started looking around today and found that I can set up a FTP connection through Windows Explorer using "My Network Places". I tested it a few times and it transfers the file really well. I saved an icon on my desktop and noticed that I have to double click into the file for it to connect before it will actually transfer any files (I tried moving files to it (not from the script) and they failed to upload). Once I clicked the icon for the FTP and connected / open it, navigated to my files and moved them, they uploaded perfectly to the server.

I guess I'm just seeking some direction on how you guys would fix this issue. Use the "My network Places" route or "writing out the ftp script" route.

I would perfer to use the ftp script but I can't get it to transfer...

Any help is always greatly appreciated.

Rick B

Share this post


Link to post
Share on other sites
RickB75

Anyone have any advice?

Share this post


Link to post
Share on other sites
Tankbuster

I guess your problem is in

_FTP_FilePut($conn, $myFile,$folder,0,0)

I changed it (beside some debug ...) to:

$result=_FTP_FilePut($conn, $myFile,$folder&"/"&$myFile)
_DebugOut("FTP Connect Return:"&$result)

You have to give a file name not just a folder....

http://msdn.microsoft.com/en-us/library/windows/desktop/aa384170%28v=vs.85%29.aspx

lpszNewRemoteFile [in]

Pointer to a null-terminated string that contains the name of the file to be created on the remote system.

#include <FTPEx.au3>
#include <Debug.au3>
$host = "ftp.MyWebsite.com"      ; Hostname of the webserver (Can be a domain name or an IP)
$user = "Username"       ; FTP Username
$pass = "Password"       ; FTP Password
$folder = "/targetfolder"        ; This is the folder where your files will upload to

$myFile = "test1.txt"
_DebugSetup("Debug", True,2)

$open = _FTP_Open("Myftp")
_DebugOut("FTP Open Return:"&$open)
$conn = _FTP_Connect($open, $host, $user, $pass,0,0)
_DebugOut("FTP Connect Return:"&$conn)
_FTP_Connect($open, $host, $user, $pass,0,0)) ;### Debug MSGBOX
$result=_FTP_FilePut($conn, $myFile,$folder&"/"&$myFile)
_DebugOut("FTP Connect Return:"&$result)
_FTP_Close($open)

Do you agree with that?

Share this post


Link to post
Share on other sites
RickB75

Mr. TankBuster,

I will take any advice that I can get. Let try this and I will let you know if it works.

Share this post


Link to post
Share on other sites
RickB75

It did didn't work Tank. This is what the console gave me back.

FTP Open Return:0x00CC0004

FTP Connect Return:0x00CC0008

FTP Connect Return:0

I don't understand how filezilla can connect but I can't get this to.

Edited by RickB75

Share this post


Link to post
Share on other sites
Tankbuster

I tested it with the ftp on my personal NAS and it worked (this phrase is most like by persons asking for help adn ending up not working on their part...I know)

Based on the Console output the connect and the open is ok, it is still the FtpFileput.

Could you change the one line? And post the Error value. Maybe we get a nice Ftp return code.

_DebugOut("FTP FilePut Return:"&$result&" - Error:"&@error)

Based on your return: The user and Pass should be no issue. My best guess is that is a) either your path, file string

or

B) The ftp server set up (differetn than default). Maybe you could post the filezilla respone on the connect (of course please remove your credentials, user , pass and IP)

Maybe it is a issue of acii or binary?

Q: You first wrote "it did" than you chnaged to "it didn't" - Why?

Edited by Tankbuster

Share this post


Link to post
Share on other sites
RickB75

Sorry about the "did" statement. It was a typo. here is what was returned from Autoit

FTP Open Return:0x00CC0004

FTP Connect Return:0x00CC0008

FTP FilePut Return:0 - Error:-1

And here is the info from Filezilla

Status: Resolving address of MyWebsite.com

Status: Connecting to xx.xx.xx.xx.xx.x

Status: Connection established, waiting for welcome message...

Response: 220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------

Response: 220-You are user number 14 of 500 allowed.

Response: 220-Local time is now 15:43. Server port: 21.

Response: 220-This is a private system - No anonymous login

Response: 220 You will be disconnected after 3 minutes of inactivity.

Command: USER xxxxxxx

Response: 331 User xxxxxxxx OK. Password required

Command: PASS ***********

Response: 230 OK. Current restricted directory is /

Command: SYST

Response: 215 UNIX Type: L8

Command: FEAT

Response: 211-Extensions supported:

Response: EPRT

Response: IDLE

Response: MDTM

Response: SIZE

Response: MFMT

Response: REST STREAM

Response: MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;

Response: MLSD

Response: AUTH TLS

Response: PBSZ

Response: PROT

Response: UTF8

Response: ESTA

Response: PASV

Response: EPSV

Response: SPSV

Response: ESTP

Response: 211 End.

Command: OPTS UTF8 ON

Response: 200 OK, UTF-8 enabled

Status: Connected

Status: Retrieving directory listing...

Command: CWD /windowsticker

Response: 250 OK. Current directory is /windowsticker

Command: PWD

Response: 257 "/windowsticker" is your current location

Command: TYPE I

Response: 200 TYPE is now 8-bit binary

Command: PASV

Response: 227 Entering Passive Mode (xx,xx,xx,x,xxx,xxx)

Command: MLSD

Response: 150 Accepted data connection

Response: 226-Options: -a -l

Response: 226 3972 matches total

Status: Directory listing successful

Share this post


Link to post
Share on other sites
BrewManNH

The server appears to be using TLS, I am not sure if the FTP functions will work with the server you're connecting to.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
kylomas

RickB75,

This is a func that I use to xfer files to my WEB site. The error mesages may confirm BrewmanNH's suspicions.

Func FTPlog($lfn,$rfn)

    Local $server       = '**************.com'
    Local $username     = '********'
    Local $pass         = '********'

    Local $Open = _FTP_Open('Samolyk FTP')
    If $open = 0 Then
        MsgBox(0,'Open Error',@error & @LF & _WinAPI_GetLastErrorMessage())
        Exit
    endif

    Local $Conn = _FTP_Connect($Open, $server, $username, $pass)
    If $conn = 0 Then
        MsgBox(0,'Connect Error',@error & @LF & _WinAPI_GetLastErrorMessage())
        exit
    endif

    Local $put  = _FTP_FilePut($conn,$lfn,"/www/KLMS/" & $rfn)
    If $put = 0 Then
        MsgBox(0,'File Put Error',@error & @LF & _WinAPI_GetLastErrorMessage())
        exit
    EndIf

    Local $Ftpc = _FTP_Close($Open)
    If $ftpc = 0 Then
        MsgBox(0,'FTP CLose Error',@error & @LF & _WinAPI_GetLastErrorMessage())
        exit
    EndIf

endfunc

$lfn is the FULLY QUALIFIED local file name, $rfn is the remote (WEB site) base file name (without directory).

Good Luck,

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
Tankbuster

So, if TLS is in use and it is not changeable or not a option to change.

Question:

Is the usage of a "external" app or dll an option for you?

Eg. the use of putty, wput or maybe some other software without a license issue

As far as I remember way back I changed at a certain point also to external apps instead of using pure au3.

I found a promising UDF but it refers to SFTP (another issue of course), so there are already some questions on that here in the forum (maybe BrewManNH knows some ?)

But before offering solutions to you that do not fit your needs, maybe it's better to ask if the direction is valid.

(just as you mentioned in the very last lines of your OP)

Share this post


Link to post
Share on other sites
RickB75

Tank

I double checked and the direction is valid. Since your last post, I've incorporated filezilla into the script. I really didn't want to have to do that but, I've ran it a few times and it's working ok. The first couple of time's I was getting errors from filezilla. I added a couple of pauses into the script and it is working correctly. This was basically a last resort but I had to get it going. My only issue is that I do have to use a mouse click and a couple of send keys ( doesn't seem as reliable) but that may just be a mental thing for me. I'm gonna keep working on it and trying to get it to work by using AutoIt. FYI - My hosting account is pretty much a basic account with Godaddy. I did upgrade it to the unlimited storage. Not sure if that makes a difference or not. I wouldn't think it would make any difference with the FTP.

Share this post


Link to post
Share on other sites
guinness

TormentoRobots,

It's [autoit][/autoit] and secondly your code contains a false understanding of how Run works and the OP's requirement.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
TormentoRobots

thank you guinesss

Edited by TormentoRobots

#Include-once;TormentoRobots

Share this post


Link to post
Share on other sites
guinness

No, that Run returns a PID not a handle to a window.


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
Tankbuster

Sorry, for the delay.....there had been some real work :-)

maybe you like to take a close look at :

http://lftp.yar.ru/features.html

This is a Windows port of lftp. I use this tool for mirroring a remote ftp site to a local share on a daily base. (yes Rsync does the same if someone asks.....but I use this tool, not comparing the tools...)

The syntax is very simple. So a "runwait" will do.

Clicking in UI is not my style. if possible I try to get around with this. But on the other hand filezilla is very "trustful" imho.

So if you use this tool, there are two ways to work with command.

Either write runtime command file or parse them with the -c.

But this just as a hind if you want to try it, in case you are not so happy with the filezilla solution.

Raise a hand if you need more help.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • Carm01
      By Carm01
      Hello,
      I am attempting to pull a list of the directory structure from a public FTP where no username or password is required i.e:
      ftp://ftp.adobe.com/pub/adobe/
      Now I have looked all over the place and have failed find anything to accomplish, and if I found some, and the documentation is rather bleak for example;
      it does show something I am looking for, but there is no ftp.au3, and the usage and examples of what i want to do seems to elude me on this and it may not even apply to what I am trying to accomplish?
      I want to avoid using things with Internet explorer , and I have done some google searches. However nothing seems to help
      the documentation surrounding : _FTP_DirGetCurrent  references _FTP_Connect , and then references _FTP_Open , and regardless what I try I cannot get it to pull a list of directorys of files as a list.
       
      Any help is appreciated
       
       
       
    • Jemboy
      By Jemboy
      Hi,
      Ones(some times twice) a month I get an e-mail with zip file, which has price updates from a supplier.
      I have to upload the file to an FTP to get it processed.
      When uploading the file, it will get "timestamped" with the time and date at which time the file was uploaded.
      Normally this is fine, because I mostly upload the file the same day.
      Sometimes it may take 1 or 2 days before I can upload the file.
      For historical purpose, I would like to have the file timestamped with the original date.
      I have tried using:  _FTP_Command ( $hFTPSession, "MFCT YYYYMMDDHHMMSS path") 
      however this command does not work or change the timestamp as I expected.
      Does anyone now a way how I can change the timestamp of a FTP-file?
    • Sally1801
      By Sally1801
      Hello,
      i need help in deleting files from a server. The function "_FTP_DirDelete" only deletes a directory when its empty. I need to delete a non empty directory. I also can not delete the files in this directory first, because the files are PAG and DIR files in a .DAV directory and FTPEx.au3 doesnt like a directory starting with a ".".
      Any ideas?
      Thx, Sally
    • CharlieH
      By CharlieH
      Hi,
       
      I have written a small script to read a file from an FTP server and check its contents. This can be re-run by the press of a button, however, if the file is deleted from the ftp server between runs (with the .exe still live), the file is still "read" and written locally, which then passes the check.
       
      If I run it initially without the file, it correctly fails and pops up my error message, but if the file is then added, it then seemingly gets cached (or similar) so that the app then always reports a success.
       
      The below code snippet is just the function run when the "test" button is pressed. It includes a load of debug message boxes, and from that I think I've gathered a few (possibly) interesting/relevant things:
      $Open and $Conn are 8 byte values, which increments (not by 1) when the FTP connection is not closed, but if the connection is closed, they stick at the value (presumably windows can re-use that session id if it's been closed e.g:
      1st run (file not present) $Open -> 0x00CC0004 $Conn -> 0x00CC0008
      2nd run (file not present) $Open -> 0x00CC0010 $Conn -> 0x00CC0014
      3rd run (file now present) $Open -> 0x00CC001C $Conn -> 0x00CC0020
      4th run (file still present) $Open -> 0x00CC001C $Conn -> 0x00CC0020
      $Ftp = _FTP_FileGet.... returns a 1 when file not present (in a run after it was present) and "test_transfer.txt" does get created and does contain the correct string This is the key bit I dont understand, I dont know how/where it is getting the data to write this file when it literally no longer exists on the target FTP server...
      resetting every variable used in the function each time it's run does work (in that they become 0), but it doesn't affect the putcome I had thought perhaps some key values were being stored in the variables, but this doesn't seem to be the case
       
       
      Is there any concept of clearing a cache when closing an ftp session? Or deleting any unknown temporary files windows might make?
       
      Thanks all
       
      Func Transfer() Local $connected = 0 $Ftpp = 0 ;Trying to reset these every time function is called $file = 0 $Open = 0 $Conn = 0 $Ftpc = 0 ;Make a new "connecting..." window so that the user has feedback that a transfer is attempting to take place ;Otherwise it just runs in the background and there's no indication its doing anything $connection_window = GUICreate ("Ethernet Switch Test" , 300 , 160 , -1 , -1 , -1 , -1 , 0) GUISetBkColor(0xFFFFFF) GUISetFont(10 * _GDIPlus_GraphicsGetDPIRatio()[0], 400, Default, "Sans Serif") $connecting_label = GUICtrlCreateLabel("Connecting to board...", 0, 25, 300, -1, $SS_Center, "") GUISetState(@SW_SHOW, $connection_window) Sleep(100) ;Connect ;MsgBox(0, "DEBUG", "1" & $Conn) While $connected = 0 $Open = _FTP_Open($count) ;MsgBox(0, "DEBUG", "open " & $Open) $Conn = _FTP_Connect($Open, $server, $username, $password) ;MsgBox(0, "DEBUG", "2" & $Conn) If $Conn = 0 then Local $retry = Msgbox(65, 'FTP Transfer', 'Connection failed' & @CRLF & "Retry?") If $retry = 2 Then MsgBox(0, "FTP Transfer", "Operation aborted") GUISetState(@SW_HIDE, $connection_window) Return EndIf Else $connected_label = GUICtrlCreateLabel("Connected!", 0, 45, 300, -1, $SS_Center, "") $connected = 1 MsgBox(0, "DEBUG", "3" & $connected) Sleep(100) endIf WEnd $transfering_label = GUICtrlCreateLabel("Reading file....", 0, 45, 300, -1, $SS_Center, "") ;Read file from server ;MsgBox(0, "DEBUG", "5" & $Ftpp) ;MsgBox(0, "DEBUG", "flie " & $file) $Ftpp = _FTP_FileGet($Conn, 'test/test.txt', 'test_transfer.txt') ;MsgBox(0, "DEBUG", "6" & $Ftpp) If ($Ftpp) then $transfered_label = GUICtrlCreateLabel("Transfered, checking...", 0, 65, 300, -1, $SS_Center, "") ;MsgBox(0, "DEBUG", "flie " & $file) $file = FileRead("test_transfer.txt") ;MsgBox(0, "DEBUG", "flie " & $file) If Not StringInStr($file, 'this is a test string 12345') Then MsgBox(0, "File check", "Received file incorrect, test failed!") GUISetState(@SW_HIDE, $connection_window) Return Else $tested_label = GUICtrlCreateLabel("Tested and Passed!", 0, 85, 300, -1, $SS_Center, "") $Ftpc = _FTP_Close($Open) ;MsgBox(0, "DEBUG", "close" & $Ftpc) ;$count = $count+1 $ok_button = GUICtrlCreateButton("OK", 125, 105, 50, -1) While 1 Local $pressed = GUIGetMsg() If ($pressed = $ok_button) Then FileDelete("test_transfer.txt") GUISetState(@SW_HIDE, $connection_window) ;$connection_window = 0 Return EndIf WEnd EndIf Else MsgBox(0, "Transfer", "Could not read file " & @error) GUISetState(@SW_HIDE, $connection_window) Return EndIf EndFunc  
    • Sigmac
      By Sigmac
      I have used this code for a long time, but for a week or 2 it stopped working?
      Connection is ok, the put create the file on server if I delete it on the FTP server, but the file is empty and after 30 secondees the function return 0
      I have tested on 2 machines, Filezilla FTP client have no issue to the server.
      Firewall is disabled under test.
        If $writeFTP = True Then
            $Open=_FTPOpen('MyFTP Control')
            $Conn=_FTPConnect($Open, $destinationServer, $destinationUsername, $destinationPass)
       MsgBox(0,"start","start")
            $Ftpp=_FtpPutFile($Conn, $filePath&$name&".json", "httpdocs/p_calender/" & $name & ".json")
      MsgBox(0,"return","return"&$Ftpp)
      Exit
            $Ftpc=_FTPClose($Open)
           EndIf
       
      From the Lib:
      Func _FTPPutFile($l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 0, $l_Context = 0)
          Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpPutFile', 'long', $l_FTPSession, 'str', $s_LocalFile, 'str', $s_RemoteFile, 'long', $l_Flags, 'long', $l_Context)
          If @error OR $ai_FTPPutFile[0] = 0 Then
              SetError(-1)
              Return 0
          EndIf
          Return $ai_FTPPutFile[0]
      EndFunc ;==> _FTPPutFile()
       
×