?

Log in

No account? Create an account
entries friends calendar profile my webpage Previous Previous Next Next
Apache question. - Tina Marie's Ramblings
Red hair and black leather, my favorite colour scheme...
skywhisperer
skywhisperer
Apache question.
I'm rolling out the new version of my recipe database, and I've run into a wierd issue. I want to have a link at the bottom of a recipe that allows you to click on it and have a .mx2 (Mastercook) file automatically download and import.

Now, I know other sites do this, and if you download a .mx2 file from, say, CDKitchen, it launches Mastercook and imports it. But when I try it like this, when you click on the link it doesn't download - it tries to display it in Firefox as an XML file, and fails horribly (because it looks like XML but isn't really).

There's got to be some way to tell apache to always force a download of an .mx2 file, right? No amount of googling would tell me what that way is.

Anyone got any ideas? I'd very, very strongly prefer not to use JavaScript (what CDKitchen does) unless there are no other options.

Tags:
Current Mood: confused confused

2 comments or Leave a comment
Comments
From: ptomblin_lj Date: January 27th, 2007 12:55 am (UTC) (Link)
In the .htaccess file for the directory that file lives in (or you can do it in the site config file if you prefer:

AddType application/xml .mx2


Using "application/xml" instead of the default "text/xml" tells Firefox not to try to interpret it.

skywhisperer From: skywhisperer Date: January 27th, 2007 02:51 am (UTC) (Link)
Actually, no matter what I did with the type, Firefox still tried to parse it. And I validated that apache was sending the correct type.

Oddly, it seemed to work until there were spaces in the filename.

I finally gave up and wrote a download.php script that sends:

header("Content-type: application/x-mastercook");
header("Content-Disposition: attachment; filename=$fileName");

and then the data. It's not optimal, but it works.

Thanks for pointing me in the right direction!
2 comments or Leave a comment