Help needed downloading a file to a folder

Andre Garzia soapdog at mac.com
Sat Dec 3 01:09:22 EST 2005


On Dec 3, 2005, at 3:58 AM, Rodney Somerstein wrote:

> I am trying to create a button to download a file from a web site.  
> I don't seem to be having much luck getting this to work. This is  
> under OS X. At best, I seem to get a 4k text file. I should be  
> getting a 5MB zip file. As far as I can tell, this should download  
> the file to my user directory.
>
> Here is my current script:
>
> on mouseUp
>     put URL "http://cosmosui.org/index.php? 
> p=download&f=Cosmos_Alpha.zip" \
>         into URL "binfile:/Users/rodneys/Cosmos_Alpha.zip"
> end mouseUp
>
>
> It seems like this should be simple. Please help me figure out what  
> I'm doing wrong. I've looked through the documentation quite a bit  
> but haven't found anything that tells me exactly what to do to  
> accomplish this.
>
> Thanks,
>
> -Rodney
> -- 

Rodney,

you're targeting the wrong URL... if you use that URL in a browser  
you'll see that it refreshes to another URL, those 5k you're getting  
is the actual url, in this case you get cosmos/Cosmos_Alpha.zip, so  
the real url for that file is:

http://cosmosui.org/cosmos/Cosmos_Alpha.zip

pretty easy ain't it. The put URL command is a blocking command  
meaning that it will lock your user interface for the duration of the  
command which might not be the desired behaviour for a 5meg download  
ui. It's better to use the load url command which is non-blocking,  
this way your UI will be responsive while the download goes and your  
code will be notified when the download finishes, much better.

cheers
andre


More information about the use-livecode mailing list