1. --!movie
  2. --!encoding=utf-8
  3.  
  4. global $
  5.  
  6. ----------------------------------------
  7. -- Upload file with ftp (synchronous/blocking mode)
  8. ----------------------------------------
  9. on startMovie
  10.     _player.debugPlaybackEnabled = 1
  11.  
  12.     -- libs
  13.     $.import("curl")
  14.  
  15.     -- config
  16.     tLocalFile = $.PATH & "ftp_upload.lsw" -- this script file
  17.     tRemoteFile = "ftp://domain.com/test/ftp_upload.lsw"
  18.     tUsername = "john.doe"
  19.     tPassword = "********"
  20.  
  21.     -- get a CURL handle (xtra instance)
  22.     ch = $.curl.init()
  23.  
  24.     -- specify options
  25.     ch.setOption($.curl.CURLOPT.URL, tRemoteFile)
  26.     ch.setOption($.curl.CURLOPT.USERNAME, tUsername)
  27.     ch.setOption($.curl.CURLOPT.PASSWORD, tPassword)
  28.     ch.setOption($.curl.CURLOPT.UPLOAD, 1)
  29.  
  30.     -- upload source
  31.     ch.setSourceFile(tLocalFile)
  32.  
  33.     -- returnMode: 0=return error code (=default), 1=return data
  34.     res = ch.exec(0) -- we don't want to return data
  35.  
  36.     put "UPLOAD FINISHED!"
  37.     put "ERROR:" && curl_error(res)
  38.  
  39.     --put "SPEED_UPLOAD:" && ch.getInfo($.curl.CURLINFO.SPEED_UPLOAD)
  40.     --put "TOTAL_TIME:" && ch.getInfo($.curl.CURLINFO.TOTAL_TIME)
  41. end
  42.  
[raw code]