Write variable to a file on a server?

Mike Bonner bonnmike at gmail.com
Sat Aug 8 09:05:41 EDT 2015


You need to set up a script to catch the data, and you need to send the
data using a key=data type format.

So for example if you're sending a book chapter to your server, and the
text of the chapter is in variable tChapter

post ("chapter1=" & urlencode(tChapter)) to URL "
http://myUrl.com/myscript.lc"
put it -- will put whatever is returned into the msg box


For the script itself, since we know the key name..

<?lc
if $_POST["chapter1"] is not empty then -- post is a special variable where
posted data is held
put $_POST["chapter1"] into URL "file:chapter1.txt" -- put the data into a
file
put "chapter saved" -- send a message back that the chapter was saved
else
put "no chapter sent" -- send an error message back
end if
?>

Obviously this is a very simple example that wouldn't be very useful, but
hopefully it will give you the idea.

The chapter1.txt file will be created right next to your script (since i
didn't tell it elsewhere) so to look at the file you would go to
http://myUrl.com/chapter1.txt

On Sat, Aug 8, 2015 at 5:39 AM, Tim Selander <selander at tkf.att.ne.jp> wrote:

> Hi,
>
> Messing with a LC script in a web page, writing a variable to a text file
> on my on-rev server account.
>
> The dictionary says the postmyData toURL"
> http://www.example.net/indications.cgi" should work, but it doesn't. I
> get an 404 error.
>
> I am trying to save a variable's text contents by using
> post myData to URL "http://www.mydomain.info/data.txt"
>
> Can anyone tell me the proper way?
>
> Thanks,
>
> Tim Selander
> Tokyo, Japan
> _______________________________________________
> 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