Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Contacting and editing server files in Codea

edited July 2014 in General Posts: 142

I was just wondering if there was any way of editing or exporting files on a server. I know you can receive images and text files using http.request , but is there any way to upload files directly from Codea to an internet server?

Comments

  • Posts: 2,042

    Use http.request with the POST method.

  • edited July 2014 Posts: 142

    @JakAttak Sorry, but is there any way you could explain this more? When you use this method what exactly happens?

  • edited July 2014 Posts: 2,042

    @Staples, something like this:

    local headers = {}
    headers["Accept"]="text/plain"
    headers["Content-Type"]="application/x-www-form-urlencoded"
    headers["Accept-Charset"]="utf-8"
    
    local data = "thing1=" .. value1 .. "&thing2=" .. value2
    
    http.request(url, success, failure, { method = "POST", headers = headers, data = data })
    

    You could add or remove data entries as you please.

    Then it's up to your sever script to handle the data sent (it is stored in either $_POST or $HTTP_RAW_POST_DATA for php, I don't remember which one)

Sign In or Register to comment.