1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-12-25 17:08:22 +01:00

allow single multiple upload file

This commit is contained in:
Dany LE 2021-11-21 19:13:06 +01:00
parent 175f952f23
commit bb88057ec1
3 changed files with 15 additions and 4 deletions

Binary file not shown.

View File

@ -191,6 +191,7 @@ function VFSController:upload(...)
if r then
result(r)
else
self:error(m)
fail(m)
end
else

View File

@ -141,13 +141,23 @@ vfs.write = function(path,data)
end
vfs.upload = function(path)
if(not path) then
return false, "Unknown upload destination, abort!"
end
local r,m = vfs.checkperm(path,"write")
if(r) then
local uid = ulib.uid(SESSION.user)
local file = m.."/"..REQUEST["upload.file"]
ulib.move(REQUEST["upload.tmp"], file)
ulib.chown(file, uid.id, uid.gid)
return true, nil
local index = 0
while(REQUEST["upload-"..index..".tmp"] ~= nil) do
local file = m.."/"..REQUEST["upload-"..index..".file"]
ulib.move(REQUEST["upload-"..index..".tmp"], file)
ulib.chown(file, uid.id, uid.gid)
index = index + 1
end
if(index == 0) then
return false, "No file is uploaded"
end
return true, index
else
return r,m
end