Serving a dynamically created file, plus extra HTML?
Posted: Thu Apr 15, 2010 1:33 am
I have a script that takes some GET variables and creates a KML file for Google Earth. The headers are set such that as soon as the page loads, the KML is echoed, the browser downloads it, and Google Earth opens it automatically. However, I can't seem to do anything after that. What I want to do is echo a line of Javascript that closes the tab/window automatically, since the page itself is useless other than serving the KML. All you end up with is a blank window.
If I try to add code after the KML is echoed, it adds that to the KML, which causes Google Earth to complain about junk data. I tried using flush(), but that didn't work. I guess I'm trying to set it up like a lot of download pages you see; the file download popup is raised, but there's still HTML echoed to the window (obviously, since if there weren't, it would just be a blank page). Anyone know how to do that?
Note: If the Content-Disposition header is set to inline, the file downloads in the background automatically. If it's set to attachment, it always raises the download dialog ("What would you like to do with this file?"). Since this all needs to be as streamlined as possible, a download confirmation dialog is not acceptable.
Thanks for the help in advance.
If I try to add code after the KML is echoed, it adds that to the KML, which causes Google Earth to complain about junk data. I tried using flush(), but that didn't work. I guess I'm trying to set it up like a lot of download pages you see; the file download popup is raised, but there's still HTML echoed to the window (obviously, since if there weren't, it would just be a blank page). Anyone know how to do that?
Note: If the Content-Disposition header is set to inline, the file downloads in the background automatically. If it's set to attachment, it always raises the download dialog ("What would you like to do with this file?"). Since this all needs to be as streamlined as possible, a download confirmation dialog is not acceptable.
Thanks for the help in advance.