Force the download

Hello,

I wonder if you could tell me how to make the navigator force the
download.

In PHP it works like this:

$downloadfile=“fichero.gpx”;
header(“Content-disposition: attachment; filename=$downloadfile”);
header(“Content-Type: application/force-download”);
header(“Content-Transfer-Encoding: binary”);
header("Content-Length: ".strlen($myGPXCode));
header(“Pragma: no-cache”);
header(“Expires: 0”);
echo $myGPXCode;

What would be a similar code to the above for Ruby on Rails?

Thank you.

On 11/6/07, David B. [email protected] wrote:

$downloadfile=“fichero.gpx”;
header(“Content-disposition: attachment; filename=$downloadfile”);
header(“Content-Type: application/force-download”);
header(“Content-Transfer-Encoding: binary”);
header("Content-Length: ".strlen($myGPXCode));
header(“Pragma: no-cache”);
header(“Expires: 0”);
echo $myGPXCode;

What would be a similar code to the above for Ruby on Rails?

send_data myGPXCode, :filename => ‘fichero.gpx’

You can’t actually “force” the browser to do anything, but this gives
the proper “suggestions” to the browser to trigger the “save as”
dialog…

You are looking for send_file:

-Bill

Bob S. wrote:

What would be a similar code to the above for Ruby on Rails?

send_data myGPXCode, :filename => ‘fichero.gpx’

You can’t actually “force” the browser to do anything, but this gives
the proper “suggestions” to the browser to trigger the “save as”
dialog…


Sincerely,

William P.