Hi Simon: Well, you helped me figure out a bit more. Your script works, but not in the arrangement I'm using (maybe I need to rethink).
I think my problem is I'm trying to trigger the download by reloading the same page. I have the lcserver code near the top of the page (note I simplified your code): <?lc if number of lines in the keys of $_POST > 0 then put header "Content-type: application/zip" put header "Content-Disposition: attachment; filename=sound.zip" put header "Content-Transfer-Encoding: binary" put url "binfile:files/sound.zip" into theFile put theFile end if ?> Then there'a simple form on the page: <form method="post" action="index.lc"> <input type="hidden" name="get" value="true"/> <button type="submit">GET FILE</button> </form> If I place only (the modified version of) your code on a simple page and load it in a browser, it downloads the ZIP as expected. When I run all of the above on a page and press the submit button, the raw code of the ZIP gets written to browser window (Chrome OS X). So maybe I need to figure out another way of loading a page that contains the download code. I've tried using redirects and get the same problem -- raw code in the browser. I don't get what the difference is between loading a URL via the browser's address field, and "put"-ting a URL via lcserver. Thanks & Regards, Scott Rossi Creative Director Tactile Media, UX/UI Design On 4/25/14 1:23 AM, "Simon Smith" <he...@simonsmith.co> wrote: >Hi Scott > >Played around with it in LiveCode and got this works for me: > ><?lc > >put header "Content-type: application/zip" >put header "Content-Disposition: attachment; filename=myFile.zip" >put header "Content-Transfer-Encoding: binary" > >put "myPDF.zip" into fileToRead >open file fileToRead for binary read > read from file fileToRead until EOF > close file fileToRead >put binary it > >lc ?> > > > >On Fri, Apr 25, 2014 at 8:38 AM, Scott Rossi <sc...@tactilemedia.com> >wrote: > >> Thanks Simon. This will likely do what I need. >> >> But I'd really like to know how to do this with lcserver. That's the >> point, right? Not to have to rely on PHP? :-) >> >> What's the LC equivalent of what readfile() is doing below? >> >> Thanks & Regards, >> >> Scott Rossi >> Creative Director >> Tactile Media, UX/UI Design >> >> >> >> >> On 4/24/14 11:03 PM, "Simon Smith" <he...@simonsmith.co> wrote: >> >> >Hi Scott >> > >> >I have done something similar in php before, where a page loads, and >>then >> >the file starts downloading a few seconds later, without leaving the >>main >> >page. >> > >> >The main page contains a refresh tag that loads the script that starts >>the >> >download: >> > >> ><meta http-equiv="refresh" content="2;url=sendfile.php" /> >> > >> >and then the sendfile.php consists of: >> > >> ><?php >> >header('Content-type: application/pdf'); >> >header('Content-Disposition: attachment; filename="' . >> >basename('filename.pdf') . '"'); >> >header('Content-Transfer-Encoding: binary'); >> >readfile($filename); >> >?> >> > >> >Hope this helps. >> >Simon >> > >> > >> >On Fri, Apr 25, 2014 at 7:21 AM, Scott Rossi <sc...@tactilemedia.com> >> >wrote: >> > >> >> Hi Peter: >> >> >> >> I started setting up a test page to demonstrate, and now I can't get >> >> anything to work, not even my single page test which worked a dozen >> >>times >> >> yesterday. [sigh] Not sure what changed. >> >> >> >> At any rate, I've seen PHP examples that involve setting content >>headers >> >> to facilitate a file transfer, so I figured since lcserver operates >> >> similarly, it should be possible to initiate the download of a zipped >> >>file >> >> (or any file). >> >> >> >> Any examples out there that someone can point me to? >> >> >> >> Thanks & Regards, >> >> >> >> Scott Rossi >> >> Creative Director >> >> Tactile Media, UX/UI Design >> >> >> >> >> >> >> >> >> >> On 4/24/14 6:17 PM, "Peter W A Wood" <peterwaw...@gmail.com> wrote: >> >> >> >> >Hi Scott >> >> > >> >> >What is the URL of the iframe? Does it include characters such as >>"?" >> >>or >> >> >"&" ? >> >> > >> >> >Regards >> >> > >> >> >Peter >> >> > >> >> >On 25 Apr 2014, at 08:29, Scott Rossi wrote: >> >> > >> >> >> Hello List: >> >> >> >> >> >> I'm hoping someone knowledgable about server stuff has a solution >>to >> >>a >> >> >> problem I have delivering a file using lcServer via an iframe. >> >> >> >> >> >> I'm using lcServer with the following code to trigger a file >> >>download: >> >> >> >> >> >> put url ("binfile:files/sound.zip") into theFile >> >> >> put header "Content-Disposition: attachment; filename=" & quote & >> >> >> "sound.zip" & quote >> >> >> put new header "Content-Type: application/force-download" >> >> >> put new header "Content-Type: application/zip" >> >> >> put new header "Content-Type: application/octet-stream" >> >> >> put new header "Content-Type: application/download" >> >> >> put header "Content-Description: File Transfer" >> >> >> put header "Content-Length:" && the length of theFile >> >> >> put theFile >> >> >> >> >> >> This appears to work fine from basic web page -- a download is >> >>triggered >> >> >> in the browser and the file is written to the drive. >> >> >> >> >> >> When I run the same code on a page within an iframe, I get the raw >> >>file >> >> >> code posted to the iframe. :-( >> >> >> >> >> >> All pages reside in the same domain (no cross domain issues) so >>I'm >> >>at a >> >> >> loss on how to deal with this. Any ideas? >> >> >> >> >> >> Thanks & Regards, >> >> >> >> >> >> Scott Rossi >> >> >> Creative Director >> >> >> Tactile Media, UX/UI Design >> _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode