1. --!movie
  2. --!encoding=utf-8
  3.  
  4. global $
  5.  
  6. ----------------------------------------
  7. -- Send data and files with HTTP POST (multipart/form-data-encoding)
  8. -- (synchronous or blocking mode)
  9. ----------------------------------------
  10. on startMovie
  11.     _player.debugPlaybackEnabled = 1
  12.  
  13.     -- libs
  14.     $.import("curl")
  15.  
  16.     -- get a CURL handle (xtra instance)
  17.     ch = $.curl.init()
  18.  
  19.     -- specify options
  20.     ch.setOption($.curl.CURLOPT.URL, "http://valentin.dasdeck.com/xtras/curl_xtra/.test/echo.php")
  21.     --ch.setOption($.curl.CURLOPT.POST, 1) -- not required, POST automatically used when form data is assigned
  22.  
  23.     -- create a form list
  24.     form = []
  25.  
  26.     -- add a POST variable
  27.     section = [:]
  28.     section.addProp($.curl.CURLFORM.COPYNAME, "foo")
  29.     section.addProp($.curl.CURLFORM.COPYCONTENTS, "äöü")
  30.     form.add(section)
  31.  
  32.     -- add another POST variable
  33.     section = [:]
  34.     section.addProp($.curl.CURLFORM.COPYNAME, "bar")
  35.     section.addProp($.curl.CURLFORM.COPYCONTENTS, "hello world")
  36.     form.add(section)
  37.  
  38.     -- add a FILE upload
  39.     section = [:]
  40.     section.addProp($.curl.CURLFORM.COPYNAME, "file1")
  41.     section.addProp($.curl.CURLFORM.FILE, $.PATH & "http_get.lsw")
  42.     form.add(section)
  43.  
  44.     -- add another FILE
  45.     section = [:]
  46.     section.addProp($.curl.CURLFORM.COPYNAME, "file2")
  47.     section.addProp($.curl.CURLFORM.FILE, $.PATH & "http_post.lsw")
  48.     form.add(section)
  49.  
  50.     ch.setForm(form)
  51.  
  52.     -- returnMode: 0=return error code (=default), 1=return data
  53.     res = ch.exec(1)
  54.  
  55.     if integerP(res) then
  56.         put "ERROR:" && curl_error(res)
  57.     else
  58.         put "RESULT:" && res.readRawString(res.length)
  59. --      put "SPEED_UPLOAD:" && ch.getInfo($.curl.CURLINFO.SPEED_UPLOAD)
  60. --      put "SPEED_DOWNLOAD:" && ch.getInfo($.curl.CURLINFO.SPEED_DOWNLOAD)
  61. --      put "TOTAL_TIME:" && ch.getInfo($.curl.CURLINFO.TOTAL_TIME)
  62.     end if
  63. end
  64.  
[raw code]