Lua download POST request

I working with Corona and like to create a server that can store data that comes posted by a ordinary browser.

I am at the Point where I get the “POST” sequence and now would just need to store the incoming data.

some problems. After the Post I do not just get the file, first are coming several headers and a “content-type” with a boundary= Info like “----WebKitFormBoundary1AA …”

For now I try to analyze each single Line I get for the first beginning of that boundary sequence and the second time (end boundary). My Code looks quiet messed up and I am sure there should be an easier option. Should U have a Solution, please post.

Thanks Chris

Here my code that is handled in a loop

_in loop after no error from: local request, err = client:receive()

[code]
if request:sub(1,4) == “POST” then
print (“GOT DATA UPLOAD”)

request,err = client:receive()
local state = 0
local lastdummy = “”

while state ~= 3 and not err do
request,err = client:receive()

– data between bounderies
if state == 2 then
if request == “\r” then print ("----OK"); end

print (request)

end

if state == 0 and request:sub(1,13) == “Content-Type:” then
a,b = string.find (request, “boundary=”)
if a > 0 then
lastdummy = (string.sub(request,b+1))
state = 1
end
elseif state == 1 then
if request == “–”…lastdummy then
print (“startttt”)
state = 2
end
elseif state == 2 then
if request == “–”…lastdummy then
print (“ENNNNND”)
state = 3
end
end

end
state = 0
print (“done”)
end
[/code] [import]uid: 4795 topic_id: 15995 reply_id: 315995[/import]