<% require("nixio.fs") require("nixio.util") require("luci.http") require("luci.dispatcher") local field = luci.http.formvalue('field') local request = luci.dispatcher.context.args local path = { '' } for i = 1, #request do if request[i] ~= '..' and #request[i] > 0 then path[#path+1] = request[i] end end local filepath = table.concat( path, '/' ) local filestat = nixio.fs.stat( filepath ) local baseurl = luci.dispatcher.build_url('admin', 'filebrowser') if filestat and filestat.type == "reg" then table.remove( path, #path ) filepath = table.concat( path, '/' ) .. '/' elseif not ( filestat and filestat.type == "dir" ) then path = { '' } filepath = '/' else filepath = filepath .. '/' end local entries = nixio.util.consume((nixio.fs.dir(filepath))) -%>
Location: <% for i, dir in ipairs(path) do %> <% if i == 1 then %> (root) <% elseif next(path, i) then %> <% baseurl = baseurl .. '/' .. dir %> / <%=dir%> <% else %> <% baseurl = baseurl .. '/' .. dir %> / <%=dir%> <% end %> <% end %>