diff --git a/controllers/VFSController.lua b/controllers/VFSController.lua index 2e1028f..ce2d6c1 100644 --- a/controllers/VFSController.lua +++ b/controllers/VFSController.lua @@ -186,8 +186,9 @@ end function VFSController:upload(...) auth_or_die("User unauthorized. Please login") local vfs = require("vfs") - if REQUEST and REQUEST.path then - local r, m = require("vfs").upload(REQUEST.path) + --LOG_DEBUG("UPLOAD COMMAND: %s", JSON.encode(REQUEST)) + if REQUEST and REQUEST.multipart and REQUEST.multipart.path then + local r, m = require("vfs").upload(REQUEST.multipart.path) if r then result(r) else diff --git a/libs/vfs.lua b/libs/vfs.lua index 0d9bd9a..ae05e95 100644 --- a/libs/vfs.lua +++ b/libs/vfs.lua @@ -149,11 +149,13 @@ vfs.upload = function(path) if (r) then local uid = ulib.uid(SESSION.user) local index = 0 - while (REQUEST["upload-" .. index .. ".tmp"] ~= nil) do - local file = m .. "/" .. REQUEST["upload-" .. index .. ".file"] - local ret = ulib.move(REQUEST["upload-" .. index .. ".tmp"], file) + while (REQUEST.multipart["upload-" .. index] ~= nil) do + local file_data = JSON.decodeString(REQUEST.multipart["upload-" .. index]) + + local file = m .. "/" .. file_data.file + local ret = ulib.move(file_data.tmp, file) if not ret then - ret = ulib.send_file(REQUEST["upload-" .. index .. ".tmp"], file) + ret = ulib.send_file(file_data.tmp, file) end if not ret then return false, "Unable to copy file"