X-Git-Url: https://git.rvb.name/lua-filemanager.git/blobdiff_plain/2ab2f7398805613c07c9d31c2968537928b87a39..HEAD:/www/cgi-bin/fs-upload?ds=sidebyside diff --git a/www/cgi-bin/fs-upload b/www/cgi-bin/fs-upload index 46d047e..101c841 100755 --- a/www/cgi-bin/fs-upload +++ b/www/cgi-bin/fs-upload @@ -1,21 +1,11 @@ #!/usr/bin/lua local cgi = require "cgi" -local uci = require("uci") -local fs = require("nixio.fs") -local os = require("os") -local json = require("json") +local fs = require "nixio.fs" +local luafm = require "luafm" local req = {} -local function is_in_dir(file, dir) - if file == dir then - return true - else - return file:sub(1, #dir) == dir - end -end - print("\r") cgi.new(req) @@ -27,15 +17,11 @@ end destfile=io.open(req.post["destination"][1]["tempname"],"r") destination=destfile:read("*all") -local u_c = uci.cursor() -local basepath = u_c.get("filemanager","config","basedir") - for k, v in pairs(req.post) do for j, v in pairs(req.post[k]) do if v["filename"] then - path = basepath..destination..'/'..v.filename - dir = fs.realpath(fs.dirname(path)) - if dir and is_in_dir(dir,basepath) then + path = luafm.make_new_path(destination..'/'..v.filename) + if path then fs.copy(req.post[k][j].tempname, path) end end