Uploading Files with LiveCode Server

Alex Tweedly alex at tweedly.net
Mon Dec 30 18:38:43 EST 2013


I think you're getting the error 500 because your script doesn't produce 
any output.

Just adding a line something like
    put "File uploaded OK"

near the end should be enough

(or of course, detect any errors if they do occur, include the file name 
in the message, ...)

-- Alex.

On 29/12/2013 19:26, Gregory Lypny wrote:
> 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
>
>
>
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list