end
function ovpn_upload()
- local fs = require("nixio.fs")
- local http = require("luci.http")
- local util = require("luci.util")
- local uci = require("luci.model.uci").cursor()
- local upload = http.formvalue("ovpn_file")
- local name = http.formvalue("instance_name2")
- local file = "/etc/openvpn/" ..name.. ".ovpn"
+ local fs = require("nixio.fs")
+ local http = require("luci.http")
+ local util = require("luci.util")
+ local uci = require("luci.model.uci").cursor()
+ local upload = http.formvalue("ovpn_file")
+ local name = http.formvalue("instance_name2")
+ local basedir = "/etc/openvpn"
+ local file = basedir.. "/" ..name.. ".ovpn"
+
+ if not fs.stat(basedir) then
+ fs.mkdir(basedir)
+ end
if name and upload then
local fp
http.setfilehandler(
function(meta, chunk, eof)
- local data = util.trim(chunk:gsub("\r\n", "\n")) .. "\n"
- data = util.trim(data:gsub("[\128-\255]", ""))
+ local data = chunk:gsub("\r\n", "\n")
if not fp and meta and meta.name == "ovpn_file" then
fp = io.open(file, "w")