Put this function into User.js of your test and call according to the Example.
/**
* FtpPut
* To put gile on a server using WinSCP with a script file auto generated.
* Requires WinSCP free tool to be installed (c:\Program Files (x86)\WinSCP\WinSCP.com)
* Example:
* FtpPut("computer","user","password","directory","file_to_upload")
*
* returns `true` if successfull
*/
function FtpPut (/**string*/server,/**string*/login,/**string*/password,/**string*/directory,/**string*/file_to_upload)
{
var result=false
var filename = Global.GetFullPath("%WORKDIR%\..\\")+"\\"+Tester.GetTestName()+"\\script_ftp.txt"
var cmd=Global.GetFullPath("c:\\Program Files (x86)\\WinSCP\\WinSCP.com") + " /ini=nul /log="+Global.GetFullPath("%WORKDIR%\..\\")+"\\"+Tester.GetTestName()+"\\ftp.log /script="+filename
// script generator
// script example
// open ftp://user:password@computer/
// put file_to_upload directory/
// exit
File.Write(filename, "open ftp://"+login+":"+password+"@"+server+"/ \n")
File.Append(filename, "put "+file_to_upload+" "+directory+ "/ \n")
File.Append(filename, "exit")
Global.DoCmd(cmd)
//
// FTP check
if (Text.FileContains(Global.GetFullPath("%WORKDIR%\..\\")+"\\"+Tester.GetTestName()+"\\ftp.log", "Exit code: 0")) {
result=true
}
return result
}