diff --git a/os/controllers/VFSController.lua b/os/controllers/VFSController.lua index 5e41456..a34ab34 100644 --- a/os/controllers/VFSController.lua +++ b/os/controllers/VFSController.lua @@ -186,7 +186,7 @@ end function VFSController:upload(...) auth_or_die("User unauthorized. Please login") local vfs = require("vfs") - if REQUEST then + if REQUEST and REQUEST.path then local r, m = require("vfs").upload(REQUEST.path) if r then result(r) @@ -195,7 +195,7 @@ function VFSController:upload(...) fail(m) end else - fail("Query not found") + fail("Invalid query") end return false end diff --git a/os/libs/vfs.lua b/os/libs/vfs.lua index d86e18a..d537b9e 100644 --- a/os/libs/vfs.lua +++ b/os/libs/vfs.lua @@ -150,7 +150,14 @@ vfs.upload = function(path) local index = 0 while(REQUEST["upload-"..index..".tmp"] ~= nil) do local file = m.."/"..REQUEST["upload-"..index..".file"] - ulib.move(REQUEST["upload-"..index..".tmp"], file) + local ret = ulib.move(REQUEST["upload-"..index..".tmp"], file) + if not ret then + print("USEEEEEEEEEEE SENDDDDDDDDDDDDDDDDDFILE") + local ret = ulib.send_file(REQUEST["upload-"..index..".tmp"], file) + end + if not ret then + return false, "Unable to copy file" + end ulib.chown(file, uid.id, uid.gid) index = index + 1 end