Quantcast

Forums | MacLife

You are not logged in.

#1 2009-01-21 10:38 pm

resedit
Chicken Little
Royal Wombat
From: /dev/null
Registered: 1999-11-01
Posts: 50388
Website

Forcing a download

Site generates a GPX file.
when sending mimetype application/gpx+xml - firefox asks what you want to do with it, but opera loads it and tries to display a parsed version of it.

After googling a bit - I found this solution -

Code:

   if(ini_get('zlib.output_compression')) {
      ini_set('zlib.output_compression', 'Off');
      }
   header("Pragma: public");
   header("Expires: 0");
   header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
   header("Cache-Control: private",false);

   header('Content-type: application/gpx+xml');
//   header('Content-type: text/plain');

   header("Content-Disposition: attachment; filename=\"" . $record . ".gpx\"");
   header("Content-Transfer-Encoding: binary");

That seems to work properly and forces download, but I'd like to hear from the web experts, I want to make sure this isn't doing something improper that "happens" to work.

-=-
btw - does this forum support ubb tags that syntax highlight php?


In her right hand Jenny held the Bible of her mother
Jenny had a pistol in the other
-- Steve Taylor

Offline

 

#2 2009-01-22 12:35 am

Zetetic Apparatchik
Member
Registered: 2001-01-07
Posts: 8250

Re: Forcing a download

I think the only salient lines are the last two and I don't think there's anything wrong with either of those.


Join the MAF AudioScrobbler group.
Protest ist, wenn ich sage, das und das paßt mir nicht. Widerstand ist, wenn ich dafür sorge, daß das, was mir nicht paßt, nicht länger geschieht.

Offline

 

Board footer

Powered by PunBB 1.2.6
© Copyright 2002–2005 Rickard Andersson