FTP Download

Sarah Reichelt sarah.reichelt at gmail.com
Mon Feb 9 20:10:54 EST 2009


> I'm trying to download a PDF file from one ftp site, but only obtain an
> error. Why? The file is about 1Mb aprox. Trying these URL directly in the
> browser the PDF is downloaded perfectly.
>
> I use this piece of code:
>
> on mouseUp
>   libURLDownloadToFile \
>
> "ftp://<username>:<pass>@ftp.regio7.cat/regio7_manresa/R7M_01022009.pdf","regio7","status"
> end mouseUp
>
> on status
>   put the urlstatus of
> "ftp://<username>:<pass>@ftp.regio7.cat/regio7_manresa/R7M_01022009.pdf"
> into field fStatus
>
> end status
>
> Nothing. What I doing wrong? I need download every day a PDF file from one
> ftp and upload to another, and save a copy of the PDF in the local hard
> disk.


What error do you get?

One useful debugging tool is to create a scrolling field (called "Log"
in the example below) and use it to show the FTP log.
        libURLSetLogField the long name of fld "Log"  -- starts logging
and
        libURLSetLogField ""   -- stops logging


Here is a general FTP download script:

    libURLDownloadToFile tURL, tSaveName, downloadDone
    -- tURL = full FTP path
    -- tSaveName is the full file path for the downloaded file to be saved to
    -- downloadDone is the name of the handle to be called when the
download is finished


-- this callback handler is only used when the download has finished
--
on downloadDone pURL, pURLStatus
    -- show completion message
    put "Download complete: " & pURLStatus
end downloadDone


HTH,
Sarah



More information about the use-livecode mailing list