Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
I want my (cross platform) app to be able to download a file from my website. I want the file to download to the DESKTOP regardless of whether the user is on a Mac or Windows PC. The file to download is on my web server and I've tested the URL and the file downloads fine. I just can't seem to get it to download via script:
"load url..." will only load that URL into a cache and you have to take care what to do with the file after successful download.
But -> specialFolderPath("desktop") & "http:// www. mywebserver.com /FileToDownload. zip"
will NOT give you a valid url to download a file from! On my machine it will read: /Users/klaus2/Desktophttp://www. mywebserver.com /FileToDownload. zip
on mouseUp
## File to save to on HD:
put specialFolderPath("Desktop") & "/FileToDownload.zip" into tDownloadedFile
## File on server:
put "http://www.mywebserver.com/FileToDownload.zip" into tUrl
libUrlDownloadtoFile tUrl, tDownloadedFile
end mouseUp
Well, if I understood the question correctly (always possibly did not )
I want my (cross platform) app to be able to download a file from my website. I want the file to download to the DESKTOP regardless of whether the user is on a Mac or Windows PC.
I would think this should work (I don't have a webserver/filename to test at the moment)
on mouseUp
put URL ("file:http://www.mywebserver.com/FileToDownload.zip") \
into URL("file:" & specialFolderPath("desktop") & slash & "FileDown.zip")
end mouseUp
Now for the next hurdle. Because the aforementioned download code is part of a preOpenStack handler, when I open a sub stack within in the project, the preOpenStack code executes which I don't want. How do I avoid this when opening a sub stack?
the trick is, to put handlers like these into the script of the first CARD and not into the stack script!
This way, they will only be executed in the stack they were meant for, and no need for "dummy" handlers anymore.
The opposite way of looking at this, where you want to make sure that everything in a stack is fully up and running, is to place certain handlers, even though they are not card-specific, in the script of the first card to MAKE SURE that all is in place before they are executed. When the card script is examined by the engine, that stack is front and center. That happens after the stack is open, and way after preOpenWhatever.