FTP Help Please
Richard Gaskin
ambassador at fourthworld.com
Sat Mar 13 11:15:53 EST 2010
JACK RARICK wrote:
> I have searched the archives - but obviously not well enough
> - for a stack or help in using FTP from a stack.
>
> Does anyone know of a stack out there that I could tear apart
> (which is how I learn best) and learn the following:
>
> How to connect to an FTP server. (I have one on driveHQ)
You're about to have a very good time. :)
Explicit connection isn't needed - libURL handles that for you whenever
you use one of its file transfer commands.
> How to upload a text file or image to that server.
put url ("file:"& tMyLocalFile) into url tMyServerUrl
Where tMyServerUrl is in the standard format for including protocol,
login, and password, e.g:
ftp://user:password@ftp.domain.com/folder/filename.txt
> How to download a different text file or image from that server.
Same thing but in reverse:
put url tMyServerUrl into url ("file:"& tMyLocalFile)
Yep, thanks to Dave Cragg and the others who've worked on Rev's libURL,
it's that easy. :)
There's a lot more libURL can do too, including providing callbacks to
let you know when a file is done transferring so you can take further
action, or providing status updates during the transfer so you can use a
progress bar. But for small text files you probably won't need a
progress bar because they'll transfer so fast. Just check "the result"
after each libURL call to see if anything went wrong, and take
appropriate action from there:
put url tMyServerUrl into url ("file:"& tMyLocalFile)
if the result is not empty then
answer "An error occurred while downloading: "& the result
exit to top
end if
Complete docs and other helpful notes on libURL are in the RevTalk
Dictionary and here:
<http://www.lacscentre.com/liburl/liburldoc.html>
--
Richard Gaskin
Fourth World
Rev training and consulting: http://www.fourthworld.com
Webzine for Rev developers: http://www.revjournal.com
revJournal blog: http://revjournal.com/blog.irv
More information about the use-livecode
mailing list