Posted 22 May 2014 - 04:09 PM
Hello..
I dont know if i should post this as a comment in my topic about listing all files on computer,
but this isnt about the same program, so i thought it would be better to start this topic in general.
I am making an upload.php site, where i can upload files..
But its long time since i last used php, and i cant remember much of the functions.
So i thought about making everything in lua, then if someone could help me convert into PHP.
my code:
The most "hard" part in this convertion, would be the "startSession" thing, since i dont know how to go through loops and tables etc.
I hope this explained as much as possible about my problem
Thanks in advance.
I dont know if i should post this as a comment in my topic about listing all files on computer,
but this isnt about the same program, so i thought it would be better to start this topic in general.
I am making an upload.php site, where i can upload files..
But its long time since i last used php, and i cant remember much of the functions.
So i thought about making everything in lua, then if someone could help me convert into PHP.
my code:
Spoiler
local postedFileData = post["fileData"]
local postedAuth = post["auth"]
local postedMethod = post["method"]
local postedFileName = post["fileName"]
local uploadPath = "http://somerandomwebsite.com/uploads/"
local currentID = 0
if postedMethod == "startSession" then
local folderIDS = fs.list( uploadPath )
if posted
currentID = 0
for k,v in pairs( folderIDS ) do
currentID = currentID + 1
end
fs.makeDir( uploadPath .. tostring( currentID ) )
elseif postedMethod == "inSession" then
-- Now this dir is ( for example )
if string.find( postedFileName, "/" ) then
-- if the path includes folders which isnt created in
-- this folder, create it.
end
-- Now all paths are completed...
-- now to create the file uploaded
local fileOpened = fs.open( uploadPath .. tostring( currentID ) .. "/" .. postedFileName, "w" )
fileOpened.write( postedFileData )
fileOpened.close()
return true, currentID -- IN PHP this should be echo 'true|' . currentID
end
The most "hard" part in this convertion, would be the "startSession" thing, since i dont know how to go through loops and tables etc.
I hope this explained as much as possible about my problem
Thanks in advance.