summaryrefslogtreecommitdiffhomepage
path: root/libs/cbi/luasrc/view
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2008-09-23 00:10:51 +0000
committerJo-Philipp Wich <jow@openwrt.org>2008-09-23 00:10:51 +0000
commit6b3985b6be52063c09f779b6bc509bf84eedc660 (patch)
treecada805afb670f7648932f8c0e3a31ffbf512108 /libs/cbi/luasrc/view
parent225de062447d8e29d927b821b41913723f392379 (diff)
* luci/libs/cbi:
- implement file upload fields - change default enctype in forms to multipart/form-data - add upload template * luci/libs/web: - dispatch file uploads to cbi form fields * luci/i18n: - add german and english translations for file upload fields
Diffstat (limited to 'libs/cbi/luasrc/view')
-rw-r--r--libs/cbi/luasrc/view/cbi/header.htm2
-rw-r--r--libs/cbi/luasrc/view/cbi/upload.htm28
2 files changed, 29 insertions, 1 deletions
diff --git a/libs/cbi/luasrc/view/cbi/header.htm b/libs/cbi/luasrc/view/cbi/header.htm
index ce5d66d77a..3f60baf52c 100644
--- a/libs/cbi/luasrc/view/cbi/header.htm
+++ b/libs/cbi/luasrc/view/cbi/header.htm
@@ -14,7 +14,7 @@ $Id$
-%>
<%+header%>
-<form method="post" action="<%=luci.http.getenv("REQUEST_URI")%>">
+<form method="post" action="<%=luci.http.getenv("REQUEST_URI")%>" enctype="multipart/form-data">
<div>
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<input type="hidden" name="cbi.submit" value="1" />
diff --git a/libs/cbi/luasrc/view/cbi/upload.htm b/libs/cbi/luasrc/view/cbi/upload.htm
new file mode 100644
index 0000000000..7e0ab1b506
--- /dev/null
+++ b/libs/cbi/luasrc/view/cbi/upload.htm
@@ -0,0 +1,28 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<%
+ local t = require("luci.tools.webadmin")
+ local v = self:cfgvalue(section)
+-%>
+<%+cbi/valueheader%>
+ <% if v then %>
+ <%:cbi_upload Uploaded File%> (<%=t.byte_format(luci.fs.stat(v).size or 0)%>)
+ <input type="hidden"<%= attr("value", v) .. attr("name", cbid) .. attr("id", cbid) %> />
+ <input type="image" value="<%:cbi_replace%>" name="cbi.rlf.<%=section .. "." .. self.option%>" alt="<%:cbi_replace%>" title="<%:cbi_replace%>" src="<%=resource%>/cbi/reload.gif" />
+ <% else %>
+ <input type="file"<%= attr("name", cbid) .. attr("id", cbid) %> />
+ <% end %>
+<%+cbi/valuefooter%>