force as kml download

force as kml download

am 17.08.2007 00:55:06 von WindAndWaves

Hi Folk

I would like a php file to be a forced download as KML file, but I am
not sure how to do it.

I would like it

a. to have the KML extension (e.g. myfile.kml rather than myfile.php)
- I could possible do this by writing the output of myfile.php to
newly created file (myfile.kml) I guess

b. force it as a download and have the appropiate header.

I copied some code, but I am curious what you would recommend. Here is
the code I copied.

header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain
browsers
header("Content-Type: application/vnd.google-earth.kml+xml");
header("Content-Transfer-Encoding: binary");

Thank you

Nicolaas

Re: force as kml download

am 17.08.2007 01:21:01 von luiheidsgoeroe

On Fri, 17 Aug 2007 00:55:06 +0200, windandwaves
wrote:
> I would like a php file to be a forced download as KML file, but I am
> not sure how to do it.
>
> I would like it
>
> a. to have the KML extension (e.g. myfile.kml rather than myfile.php)
> - I could possible do this by writing the output of myfile.php to
> newly created file (myfile.kml) I guess

Good for less updates, lots of downloads

> b. force it as a download and have the appropiate header.

Good for rapidly changing data.

So, it depends.
--
Rik Wasmus

Re: force as kml download

am 17.08.2007 02:12:38 von WindAndWaves

On Aug 17, 11:21 am, Rik wrote:
> On Fri, 17 Aug 2007 00:55:06 +0200, windandwaves
> wrote:
>
> > I would like a php file to be a forced download as KML file, but I am
> > not sure how to do it.
>
> > I would like it
>
> > a. to have the KML extension (e.g. myfile.kml rather than myfile.php)
> > - I could possible do this by writing the output of myfile.php to
> > newly created file (myfile.kml) I guess
>
> Good for less updates, lots of downloads
>
> > b. force it as a download and have the appropiate header.
>
> Good for rapidly changing data.
>
> So, it depends.
> --
> Rik Wasmus

It will definitely be option B. Almost every download will be unique.
But I dont mind doing option A if this works better. The problem is
that the file extension is .php so when people save it, it will be
myfile.php no matter what header I sent.

Love some more help with this.

Cheers

Nicolaas

Re: force as kml download

am 17.08.2007 02:20:40 von luiheidsgoeroe

On Fri, 17 Aug 2007 02:12:38 +0200, windandwaves =

wrote:

> On Aug 17, 11:21 am, Rik wrote:
>> On Fri, 17 Aug 2007 00:55:06 +0200, windandwaves >
>> wrote:
>>
>> > I would like a php file to be a forced download as KML file, but I =
am
>> > not sure how to do it.
>>
>> > I would like it
>>
>> > a. to have the KML extension (e.g. myfile.kml rather than myfile.ph=
p)
>> > - I could possible do this by writing the output of myfile.php to
>> > newly created file (myfile.kml) I guess
>>
>> Good for less updates, lots of downloads
>>
>> > b. force it as a download and have the appropiate header.
>>
>> Good for rapidly changing data.
>>
>> So, it depends.
>
> It will definitely be option B. Almost every download will be unique.
> But I dont mind doing option A if this works better. The problem is
> that the file extension is .php so when people save it, it will be
> myfile.php no matter what header I sent.

Hmmmz, a bit unreliable, but have you tried this:

header('Content-Disposition: attachment; filename=3D"myfile.kml"');

Works for most cases. And if all else fails: if you use apache you could=
=

have an 'pseudo-url' pointing to your php file:

---.htaccess---
RewriteEngine On
RewriteRule (.*)\.kml$ $1.php [L,QSA]
---------------

So /whatever/myfile.kml will end up in /whatever/myfile.php
-- =

Rik Wasmus

Re: force as kml download

am 17.08.2007 23:49:22 von Jeremy

windandwaves wrote:
> Hi Folk
>
> I would like a php file to be a forced download as KML file, but I am
> not sure how to do it.
>
> I would like it
>
> a. to have the KML extension (e.g. myfile.kml rather than myfile.php)
> - I could possible do this by writing the output of myfile.php to
> newly created file (myfile.kml) I guess
>
> b. force it as a download and have the appropiate header.
>
> I copied some code, but I am curious what you would recommend. Here is
> the code I copied.
>
> header("Pragma: public"); // required
> header("Expires: 0");
> header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
> header("Cache-Control: private",false); // required for certain
> browsers
> header("Content-Type: application/vnd.google-earth.kml+xml");
> header("Content-Transfer-Encoding: binary");
>
> Thank you
>
> Nicolaas
>


Easy way:

header("Content-Disposition: attachment; filename="foobar.kml");

Jeremy

Re: force as kml download

am 17.08.2007 23:50:12 von Jeremy

Jeremy wrote:
> windandwaves wrote:
>> Hi Folk
>>
>> I would like a php file to be a forced download as KML file, but I am
>> not sure how to do it.
>>
>> I would like it
>>
>> a. to have the KML extension (e.g. myfile.kml rather than myfile.php)
>> - I could possible do this by writing the output of myfile.php to
>> newly created file (myfile.kml) I guess
>>
>> b. force it as a download and have the appropiate header.
>>
>> I copied some code, but I am curious what you would recommend. Here is
>> the code I copied.
>>
>> header("Pragma: public"); // required
>> header("Expires: 0");
>> header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
>> header("Cache-Control: private",false); // required for certain
>> browsers
>> header("Content-Type: application/vnd.google-earth.kml+xml");
>> header("Content-Transfer-Encoding: binary");
>>
>> Thank you
>>
>> Nicolaas
>>
>
>
> Easy way:
>
> header("Content-Disposition: attachment; filename="foobar.kml");
>
> Jeremy

Durrr.

header("Content-Disposition: attachment; filename=\"foobar.kml\"");

Haste makes waste :P

Re: force as kml download

am 18.08.2007 13:55:44 von WindAndWaves

On Aug 18, 9:50 am, Jeremy wrote:
> Jeremy wrote:
> > windandwaves wrote:
> >> Hi Folk
>
> >> I would like a php file to be a forced download as KML file, but I am
> >> not sure how to do it.
>
> >> I would like it
>
> >> a. to have the KML extension (e.g. myfile.kml rather than myfile.php)
> >> - I could possible do this by writing the output of myfile.php to
> >> newly created file (myfile.kml) I guess
>
> >> b. force it as a download and have the appropiate header.
>
> >> I copied some code, but I am curious what you would recommend. Here is
> >> the code I copied.
>
> >> header("Pragma: public"); // required
> >> header("Expires: 0");
> >> header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
> >> header("Cache-Control: private",false); // required for certain
> >> browsers
> >> header("Content-Type: application/vnd.google-earth.kml+xml");
> >> header("Content-Transfer-Encoding: binary");
>
> >> Thank you
>
> >> Nicolaas
>
> > Easy way:
>
> > header("Content-Disposition: attachment; filename="foobar.kml");
>
> > Jeremy
>
> Durrr.
>
> header("Content-Disposition: attachment; filename=\"foobar.kml\"");
>
> Haste makes waste :P

Thanks a million, that is simpler than I though!

Thank you.