From 66a6492ae5aa9779af6d22eaddf0f5f253ed1189 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Wed, 16 Jul 2008 14:26:40 +0000 Subject: libs/web: Prevent luci.http to prematurely parse the POST data modules/admin-mini: Added fw-upgrade page --- .../admin-full/luasrc/controller/admin/system.lua | 29 +++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'modules/admin-full/luasrc/controller/admin') diff --git a/modules/admin-full/luasrc/controller/admin/system.lua b/modules/admin-full/luasrc/controller/admin/system.lua index 862a741cde..14fd813c38 100644 --- a/modules/admin-full/luasrc/controller/admin/system.lua +++ b/modules/admin-full/luasrc/controller/admin/system.lua @@ -197,13 +197,30 @@ end function action_upgrade() require("luci.model.uci") + local ret = nil local plat = luci.fs.mtime("/lib/upgrade/platform.sh") - - local image = luci.http.upload("image") + local tmpfile = "/tmp/firmware.img" + + local file + luci.http.setfilehandler( + function(meta, chunk, eof) + if not file then + file = io.open(tmpfile, "w") + end + if chunk then + file:write(chunk) + end + if eof then + file:close() + end + end + ) + + local fname = luci.http.formvalue("image") local keepcfg = luci.http.formvalue("keepcfg") - - if plat and image then + + if plat and fname then local kpattern = nil if keepcfg then local files = luci.model.uci.get_all("luci", "flash_keep") @@ -214,8 +231,8 @@ function action_upgrade() end end end - ret = luci.sys.flash(image, kpattern) + ret = luci.sys.flash(tmpfile, kpattern) end - + luci.template.render("admin_system/upgrade", {sysupgrade=plat, ret=ret}) end \ No newline at end of file -- cgit v1.2.3