Uploading Files with LiveCode Server
Gregory Lypny
gregory.lypny at videotron.ca
Sun Dec 29 14:26:51 EST 2013
Hi Pierre,
Thank you kindly sharing your code. I’m afraid that it is a little too advance for my skills, and my needs are much simpler. I am able to create an upload form and move the uploaded file from the tmp folder on my Mac to another folder using a shell command. There are only two problems left that I need to fix. One is that an internal server error occurs (error 500) and it is output to the web page. The other problem is that the moved file has read and write access for group _WWW but no access for anyone else.
Here is what I did. The HTML in the web page is
<html>
<head></head>
<body>
<H1>Upload Form</H1>
<form enctype="multipart/form-data" action="submitAssignmentScript.lc" method="POST">
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
where the action, “submitAssignmentScript.lc”, simply refers to a handler named submitAssignment in a stack named myServer
<?lc
start using stack myServer.livecode
submitAssignment
?>
The handler contains the following
on submitAssignment
put the keys of $_Files[uploadedfile] into theKeys
put the long date && long time & return into output
repeat for each line thisLine in theKeys
put thisLine & ":" && $_Files[uploadedfile][thisLine] & return after output
end repeat
delete the last character of output
put output into url (dataFilePath & "Upload Info.csv")
get shell ("mv" && $_Files[uploadedfile][filename] && "../share/httpd/myData/" & “Uploaded-File.pdf")
end submitAssignment
where “Upload Info.csv” contains some information from $_Files.
If anyone can help me figure out why I’m getting the the internal server error and how I can change the moved file’s permissions, I’d much appreciate it.
Regards,
Gregory
More information about the use-livecode
mailing list