Hello,
Thank you!


Now I have it  working:

function upload_file(file,dir)
  local f = file
    if f and next(f) then
        local name = f['name']
        local file = f['contents']
        local dest = io.open(dir.."/"..name, "wb")
        if dest then
            local bytes = file
            dest:write(bytes)
            dest:close()
        return "/"..dir.."/"..name --retunrs the location to save in db
        end
    end
end


here I call it:

category.cat_img = upload_file(web.POST.cat_img, "__imgs/produtos/categorias")
category:save()




Em 31/8/2010 21:48, ykhuang escreveu:
Suppose you have a form like:

<form action="/upload.cgi" method="POST" enctype="multipart/form-data">
<input type="file" name="fileinput" id="fileinput" accept=""/>
<input type="submit" value="Upload" />
</form>

try web.POST.fileinput['content'] for file content in your orbit application.

2010/9/1 Itamar Eduardo Gonçalves de Oliveira <itamaredua...@novanis.com.br>
Hello,
I'm trying to have it work here too, but I can't find the file.
I find all other datas filled in the form.
I'm getting the data by using "web.input" to get the values.
My form enctype  is  "multipart/form-data". ( form{ method = "post",  action = "" enctype = "multipart/form-data").
I'm using Orbit, in fact I'm using ToyCMS example code.

Some one has experience or know what should I do?

Thanks.

Em 8/6/2010 22:06, ykhuang escreveu:
Hi,

I found the answer by using other's code snippet when digging in archive.
The post data will be stored in table with 'name', 'content-type', and 'contents'.


Thanks to the archive.

_______________________________________________ Kepler-Project mailing list Kepler-Project@lists.luaforge.net http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project http://www.keplerproject.org/


--

Itamar Eduardo Gonçalves de Oliveira


_______________________________________________
Kepler-Project mailing list
Kepler-Project@lists.luaforge.net
http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
http://www.keplerproject.org/

_______________________________________________ Kepler-Project mailing list Kepler-Project@lists.luaforge.net http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project http://www.keplerproject.org/


--
teste
Itamar Eduardo Gonçalves de Oliveira
Informática
+55 (66) 2101 0614
Novanis -
              Tecnologia em Produção Animal


_______________________________________________
Kepler-Project mailing list
Kepler-Project@lists.luaforge.net
http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project
http://www.keplerproject.org/

Reply via email to