Lua File Upload

I’m trying to upload files to a web page:

[lua]local path = system.pathForFile( filename, system.DocumentsDirectory )
local fh = io.open(path)
local len = fh:seek( “end”, 0 )
io.close(fh)
print(“len=” … len)

response_body = {}
http.request{
url = url … "media.aspx,
method = “POST”,
headers = {
[“Content-Type”] = “multipart/form-data”,
[“Content-Length”] = len
},
source = ltn12.source.file(io.open(path)),
sink = ltn12.sink.table(response_body)
}[/lua]

It is not working… Anyone have any suggestions on how to get it to work? Thanks! [import]uid: 4899 topic_id: 8057 reply_id: 308057[/import]

For some reason, I can’t go back and edit that… So on line #9, there is supposed to be an ending quote.

NOTE: I found a way to read this on the server side that works. But I’d still be interested in finding out if there is a better way to go about this? [import]uid: 4899 topic_id: 8057 reply_id: 28697[/import]

hi,

would you mind posting your http.request example that worked?

did you use source/sink in the end to get the data into the request in the same way as above?

thanks
j [import]uid: 6645 topic_id: 8057 reply_id: 29655[/import]

I second that request! I’d be interested in your solution. Or, as I’ve seen it put in other forums: “I needz teh codez!” [import]uid: 11636 topic_id: 8057 reply_id: 30498[/import]