<% require("luci.fs") require("luci.http") require("luci.dispatcher") local field = luci.http.formvalue('field') local request = luci.dispatcher.context.path local path = { '' } for i = 3, #request do if request[i] ~= '..' and #request[i] > 0 then path[#path+1] = request[i] end end local filepath = table.concat( path, '/' ) local filestat = luci.fs.stat( filepath ) local baseurl = luci.dispatcher.build_url('admin', 'filebrowser') if filestat and filestat.type == "regular" then table.remove( path, #path ) filepath = table.concat( path, '/' ) .. '/' elseif not ( filestat and filestat.type == "directory" ) then path = { '' } filepath = '/' else filepath = filepath .. '/' end local entries = luci.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 %>